Posted on 2011-01-25 14:21
三羽 阅读(1698)
评论(0) 编辑 收藏 所属分类:
JS 脚本
在网页中加入下列代码就知道效果了
1、=====================================================
<script type="text/javascript">
window.onbeforeunload = function()
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
openwin();
alert('查看弹出');
window.event.returnValue = ""; //这里可以放置你想做的操作代码
}
}
function openwin(){
alert();
//写下事件
}
</script>
2、==========================================================
<script type="text/javascript">
<!--
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
var warning="确认退出?";
return warning;
}
function onunload_handler(){
var warning="谢谢光临";
alert(warning);
}
// -->
</script>