本来在代码中使用的是body的onunload事件来耍行亲页面。
可是在Chrome浏览器中这个事件却不被触发。
查询网上资料Chrome是支持该事件的,为什么呢?
- Navigating to another page directly in the browser or with a link.
- Closing the current browser window or tab page.
- Reloading the current page.
- Manipulating the URL of the currently loaded page through the location object from JavaScript.
- Invoking the window.navigate method.
- Invoking the window.open or the document.open method to open a document in the same window.
HTML代码:
<head>
<script type="text/javascript">
function OnUnLoad () {
alert ("The current document will be unloaded!");
}
</script>
</head>
<body οnunlοad="OnUnLoad ()">
<b>Close this window or press F5 to reload the page.</b>
</body>
实在没则了,只会在close方法里面先执行刷新亲页面,然后调用window.close()。
要是没有关闭按钮,能是隐形调用就不知道咋弄了。