[英]JS Confirm, false, return, not working
this current piece of script to confirm whether a user wants to log out is not fully working in Safari on Mac. 当前用于确认用户是否要注销的脚本无法在Mac上的Safari中正常工作。
function log_out()
{
ht = document.getElementsByTagName("html");
ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
if (confirm('Are you sure you want to log out?'))
{
return true;
}
else
{
ht[0].style.filter = "";
return false;
}
}
It works when the user confirm they want to logout, Ok, but when the user clicks cancel, they are still logged out. 当用户确认要注销时,它可以工作,确定,但是当用户单击“取消”时,他们仍然注销。
Any ideas? 有任何想法吗?
Thanks in advance! 提前致谢!
将返回指令放在log_out调用之前
<a class="rnavtab" href="?do=logout" onclick="return log_out()">Log out</a>
Ok, but when the user clicks cancel, they are still logged out. 好的,但是当用户单击“取消”时,他们仍然注销。
After seeing your code in the comment you posted: 在您发表的评论中看到您的代码后:
<a class="rnavtab" href="?do=logout" onclick="log_out()">Log out</a>
The ?do=logout
is triggered irrspective of whether a user confirms or not. 不管用户是否确认,都会触发?do=logout
。 Try putting a hash instead: 尝试放入一个哈希值:
<a class="rnavtab" href="#" onclick="log_out()">Log out</a>
You can later on redirect user like this: 您以后可以像这样对重定向用户:
window.location = '?do=logout';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.