Я создаю приложение HTML IOS с системой входа в систему.
В тот момент, когда пользователь нажимает "выйти из системы", он будет вибрировать, и появится подтверждение, чтобы сказать "вы уверены, что хотите выйти из системы" есть два ответа... "ОК" и "Отмена".
Я хочу, чтобы OK перешел на index.html, но CANCEL остался на той же странице (не выходил из системы).
В настоящий момент оба Ok и Cancel направляют на 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>
С телефонной связью вы должны сделать что-то подобное
<!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>
vibrate()
. пометить правильно, если работает