gpt4 book ai didi

JavaScript:window.confirm 有两个窗口位置?

转载 作者:行者123 更新时间:2023-11-29 03:29:04 24 4
gpt4 key购买 nike

我正在创建一个带有登录系统的 HTML IOS 应用程序。

当用户按下“注销”时,它会振动并弹出确认信息,提示“您确定要注销吗”,有两个答案......“确定”和“取消”。

我想要确定转到index.html但取消可留在同一页面(而不是注销)。

目前“确定”和“取消”都指向index.html(参见代码)

   function vibrate() {
navigator.notification.vibrate(2000);
window.confirm('Are you sure you want to log out?')
window.location.href='index.html';
}

非常感谢您的帮助

谢谢

     <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>

<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
}

</script>
<script type="text/javascript" charset="utf-8">


document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {

}

function vibrate() {
navigator.notification.vibrate(2000);
navigator.notification.confirm('Are you sure you want to logout?',
decide,
'confirm logout?',
['cancel','ok'],
);
}
function decide(button){
if(button==2){
window.location.href='index.html';
}else{
//Another stuff
}
}

</script>

<title>Logged in</title>
</head>
<body>
<h1>Welcome</h1>

<p><a href="2index.html">Home</a></p>
<p><a href="2courses.html">Courses</a></p>


<input type="button" value="Log Out"onClick="vibrate();">
</body>
</html>

最佳答案

对于 phonegap 你应该做这样的事情

     <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>



<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {

}

function vibrate() {
navigator.notification.vibrate(2000);
navigator.notification.confirm('Are you sure you want to logout?',
decide,
'confirm logout?',
['cancel','ok']
);
}


function decide(button){
if(button==2){
window.location.href='index.html';
}else{
//Another stuff
}
}


</script>

<title>Logged in</title>
</head>
<body>
<h1>Welcome</h1>

<p><a href="2index.html">Home</a></p>
<p><a href="2courses.html">Courses</a></p>


<input type="button" value="Log Out"onClick="vibrate();">
</body>
</html>

关于JavaScript:window.confirm 有两个窗口位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20061982/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com