[英]onunload event of JAVASCRIPT not work in Linux Firefox
Can you help me with this problem . 你能帮我解决这个问题吗? I am using Modzilla Firefox in Linux . 我在Linux中使用Modzilla Firefox。 When I close the window or reload the page the onunload event sees not work 当我关闭窗口或重新加载页面时,onunload事件显示不起作用
<html>
<head>
<title>onunload test</title>
<script type="text/javascript">
window.onunload = unloadPage;
function unloadPage()
{
alert("unload event detected!");
}
</script>
</head>
<body>
<p>Reload a new page into the browser<br />
to fire the unload event for this page.</p>
<p>You can also use the back or forward buttons<br />
to load a new page and fire this event.</p>
</body>
Try this code snippet : 试试这个代码片段:
window.onbeforeunload = function(){
return 'Are you sure you want to leave?'; // or anything you want to do
};
try to use jQuery libraries, because jquery consider different kinds of browser i think :) 尝试使用jQuery库,因为jquery考虑了我认为不同类型的浏览器:)
$( window ).unload(function() {
alert( "unload event detected!" );
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.