<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>test browser close event</title>
<script type="text/javascript">
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler() {
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth - 20;
if (b && window.event.clientY < 0 || window.event.altKey) {
// 是关闭而非刷新
var warning = "您正在关闭浏览器! 确认退出?";
return warning;
} else {
var warning = "刷新或离开";
alert(warning);
}
}
function onunload_handler() {
var warning = "谢谢光临";
alert(warning);
}
</script>
</head>
<body>
</body>
</html>
分享到:
相关推荐
browser.addLoadListener(listener); try { runnable.run(); try { if (!latch.await(30, TimeUnit.SECONDS)) { // throw new RuntimeException(new TimeoutException()); } } catch (InterruptedException ...
// Adds an `event` listener that will be invoked a single // time then automatically removed. WildEmitter.prototype.once = function (event, fn) { var self = this; function on() { self.off(event, on...
--[346,1,680] published at 2006-12-26 13:38:23 from #237 by 814--> /**--------------------------------------------------------------------------- * browser determine; */ { var ua ...
Table of Contents Introduction....................................................................................................13 Code Examples.........................................................