“console.log”存在一些问题
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/ html; charset=utf-8" />
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
document.write("loading PhoneGap");
document.addEventListener("deviceready", onDeviceReady, false);
document.write("PhoneGap loaded");
function onDeviceReady() {
alert("begin");
var myContact = navigator.service.contacts.create({"displayName": "Test User"});
myContact.gender = "male";
document.write("The contact, " + myContact.displayName + ", is of the " + myContact.gender + " gender");
alert("end");
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Create Contact</p>
</body>
</ html>
eclipse上Android模拟器的结果是:
loadingPhoneGap PhoneGap已加载 例子 创建联系人
“警报”缺失,似乎该功能不起作用,请问是什么问题?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/ html; charset=utf-8" />
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
document.write("loading PhoneGap");
document.addEventListener("deviceready", onDeviceReady, false);
document.write("PhoneGap loaded");
function onDeviceReady() {
alert("begin");
var myContact = navigator.service.contacts.create({"displayName": "Test User"});
myContact.gender = "male";
document.write("The contact, " + myContact.displayName + ", is of the " + myContact.gender + " gender");
alert("end");
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Create Contact</p>
</body>
</ html>
The result in the Android's simulator on eclipse is:
loadingPhoneGap PhoneGap loaded
Example
Create Contact
"alert" is missing, it seemed that that function did not work, what is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能本机不支持警报功能,您可以尝试使用phonegap警报代替吗?
http://docs.phonegap.com/en/1.0 .0/phonegap_notification_notification.md.html#notification.alert
It is possible the alert function might not be natively supported, can you try using the phonegap alert instead?
http://docs.phonegap.com/en/1.0.0/phonegap_notification_notification.md.html#notification.alert
它应该是:
不是
另外,您还有一些 JavaScript 排序问题。这是一个完整的工作index.html:
It should be :
not
Also, you have a few JavaScript ordering issues. Here is a complete working index.html: