举个例子:
关闭页面弹出一窗口,但刷新时不弹出<body onBeforeUnload="leave()">
<script LANGUAGE="JavaScript">
<!-- Begin
function leave() {
with(window.event){
if((clientY<0&&clientX>document.body.clientWidth)||altKey)leave1();}}
// End -->
</script>
<script LANGUAGE="JavaScript">
<!-- Begin
function leave1() {
window.open('open.html','','toolbar=no,menubar=no,location=no,height=70,width=650');
}
// End -->
</script>
关闭页面弹出一窗口,但刷新时不弹出<body onBeforeUnload="leave()">
<script LANGUAGE="JavaScript">
<!-- Begin
function leave() {
with(window.event){
if((clientY<0&&clientX>document.body.clientWidth)||altKey)leave1();}}
// End -->
</script>
<script LANGUAGE="JavaScript">
<!-- Begin
function leave1() {
window.open('open.html','','toolbar=no,menubar=no,location=no,height=70,width=650');
}
// End -->
</script>
function window.onbeforeunload()
{
if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey)
{
window.event.returnValue="这个事件不是刷新触发的");
}
}
</script>