【发布时间】:2012-12-27 02:17:56
【问题描述】:
我尝试将以下代码放入 html 并运行它,然后将其上传到我的服务器并在我的 iPhone 的 Safari 浏览器中打开链接,然后单击显示确认并没有弹出窗口!有人可以帮忙吗?
<!DOCTYPE html>
<html>
<head>
<title>Notification Example</title>
<script type="text/javascript" charset="utf-8" src="http://mobile-web-development-with-phonegap.eclipselabs.org.codespot.com/svn-history/r99/trunk/com.mds.apg/resources/phonegap/js/phonegap-1.0.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
function onDeviceReady() {
// Empty
}
// process the confirmation dialog result
function onConfirm(button) {
alert('You selected button ' + button);
}
// Show a custom confirmation dialog
function showConfirm() {
navigator.notification.confirm(
'You are the winner!', // message
onConfirm, // callback to invoke with index of button pressed
'Game Over', // title
'Restart,Exit' // buttonLabels
);
}
</script>
</head>
<body>
<p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>
</body>
</html>
【问题讨论】:
-
您正在尝试从浏览器中使用 Phonegap API。只有当您使用 Phonegap 制作本机应用程序时,它们才会起作用。确保您了解 Phonegap 是什么。
标签: ios cordova alert confirmation