适用于Chrome的onbeforeunload的替代方案 [英] alternative for onbeforeunload for Chrome
问题描述
对于onbeforeunload for Chrome有什么替代方案吗...还有我的代码
window.onbeforeunload = CloseSession;
function CloseSession(){
//如果按下浏览器关闭或alt + f4而不是后退按钮,则按需退出用户
if(( window.event.clientY< 0)&&(window.event.clientX> 40)||
(event.altKey == true && event.keyCode == 0))
window.open('LogOffUser.aspx','_ parent','left = 9999,top = 9999,width = 1px,height = 1px');
}
Is there any alternative for onbeforeunload for Chrome..here is my code
window.onbeforeunload = CloseSession;
function CloseSession() {
//log out the user from demand if browser close or alt+f4 is pressed not for back button
if ((window.event.clientY < 0) && (window.event.clientX > 40) ||
(event.altKey == true && event.keyCode == 0))
window.open('LogOffUser.aspx', '_parent', 'left = 9999, top = 9999,width=1px,height=1px');
}
推荐答案
这个问题没有任何实际意义。每当您编写Javascript以在浏览器中执行时,它可能会在任何其他浏览器中执行,因此找到特定于Chrome的解决方案,即使可能,也不会对您有所帮助。你需要编写兼容的代码。
-SA
This question does not make any practical sense. Whenever you are writing Javascript to be executed in a browser, potentially, it will be executed in any other browser, so finding a solution specific for Chrome, even if it was possible, would not help you much. You need to write compatible code.
—SA
这篇关于适用于Chrome的onbeforeunload的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!