【发布时间】:2013-11-14 07:51:44
【问题描述】:
可以这样写onbeforeunload函数吗?
window.onbeforeunload = function(evt) {
if(return true)
{
if(confirm('Are you sure you want to logout'));
{
//logout function
}
}
}
如果用户单击“离开此页面”按钮,我想要求用户注销会话。 有可能吗?
【问题讨论】:
-
如果返回 true 会怎样?只需返回
Are you sure you want to logout -
应该是
confirm而不是confitm。 -
@putvande 谢谢,我编辑了。
-
@ArunKillu 返回消息在 Firefox 浏览器上不起作用
标签: javascript browser onbeforeunload