0

为什么每次编译后电话间隙更改错误。有时它运行时没有任何错误,然后相同的代码会给出愚蠢的错误,例如尽管没有对代码进行任何更改,但找不到函数的解析错误。

这是在每次编译时给出不同错误的代码


   <html>
<head>
<link href="index.css" rel="stylesheet" type="text/css">
<link href="wrapper.css" rel="stylesheet" type="text/css">
<link href="natiweb.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script>
    <script src="jquery.mobile/jquery-1.7.2.min.js"></script>
    <script src="jquery.mobile/jquery.mobile-1.1.0.min.js"></script>



<script type="text/javascript" charset="utf-8"> 
function loadcontact()
{
    alert('load');
    //  navigator.contacts.find("*",contactSuccess, contactError);
    // find all contacts with 'Bob' in any name field
    var options = new ContactFindOptions();
    options.filter="Bob";
    options.multiple=true; 
    var fields = ["displayName", "name"];
**navigator.contacts.find(fields, contactSuccess onError, options);**
    window.location = "download.html";
}

function contactSuccess(contacts)
{
    alert('success');
        for (var i=0; i<contacts.length; i++) 
        {
            console.log("Display Name = " + contacts[i].displayName);
        }
}
function contactError(error) 
{
    alert('error');
}

</script>
</head>
<body class="index">
<p></p>
<h1 class="natiweb">NatiWeb</h1>
<form name ="choicepage" id="wrapper" >
<table id="wrapper" >
<tr><td>
<table align="center">
<tr></tr>

<p><b>Select Upload/Download</b></p>
<select name="upload/download">
<option selected >Upload</option>
<option>Download</option>
</select>
</td>
</tr>
<tr>
<td><img src="images/contact-icon.png" height="15"> Contacts </td>
<td><input name="opt" type="checkbox" value="Contacts"></td>
</tr>

<tr>
<td><input type="button" value="Back"></td>
<td><input type="submit" value="Next1" onclick="loadcontact();"></td>
</tr>
</table>
</table>
</form>
</body>
</html>

错误 1:SyntaxError: Parse error at file:///android_asset/www/choice.html:22 这里第 22 行标记为粗体

4

1 回答 1

0

您在该行缺少逗号。

还有一件事,您应该在收到成功/错误回调之后重定向用户,而不是之前。

function loadcontact()
{
    alert('load');
    //  navigator.contacts.find("*",contactSuccess, contactError);
    // find all contacts with 'Bob' in any name field
    var options = new ContactFindOptions();
    options.filter="Bob";
    options.multiple=true; 
    var fields = ["displayName", "name"];
    navigator.contacts.find(fields, contactSuccess, onError, options);

}

function contactSuccess(contacts)
{
    alert('success');
        for (var i=0; i<contacts.length; i++) 
        {
            console.log("Display Name = " + contacts[i].displayName);
        }
    window.location = "download.html";
}
function contactError(error) 
{
    alert('error');
    window.location = "download.html";
}
于 2013-03-29T19:32:30.437 回答