刷新关闭事件

来源:互联网 发布:比尔盖茨的编程能力 编辑:程序博客网 时间:2024/05/14 21:58
 

停止有document.onstop,看微软的例子

<body scroll=no>

<script>

document.onstop=fnTrapStop;

var oInterval;

window.onload=fnInit;

function fnInit(){

   oInterval=window.setInterval("fnCycle()",1);

}

function fnCycle(){

   // Do something

}

function fnTrapStop(){

   window.clearInterval(oInterval);

   alert();

}

</script>

</body>

______________________________________________________________________________________________

答7:

刷新与关闭

<body scroll=no>

<script>

document.body.onbeforeunload=aa;

function aa(){

if(event.clientY<0&&event.clientX>760||event.altKey)

alert("窗口关闭!")

else

alert("窗口刷新!")

}

</script>

</body>

答8:

移动窗口

<body>

<script>

var leftpos,toppos;

window.onload=function(){

leftpos=window.screenLeft

toppos=window.screenTop

}

document.body.onmouseover=aa;

function aa(){

if(window.screenLeft!=leftpos||window.screenTop!=toppos)

alert("窗口被移动了!")

leftpos=window.screenLeft;

toppos=window.screenTop;

setTimeout("aa()",1)

}

</script>

</body>

前进、后退、刷新、关闭都响应事件 window.onbeforeunload

想在javascript中执行窗口上的刷新按钮:

<input type=button value=刷新 onclick="history.go(0)">

2 <input type=button value=刷新 onclick="location.reload()">

3 <input type=button value=刷新 onclick="location=location">

4 <input type=button value=刷新 onclick="location.assign(location)">

5 <input type=button value=刷新 onclick="document.execCommand('Refresh')">

6 <input type=button value=刷新 onclick="window.navigate(location)">

7 <input type=button value=刷新 onclick="location.replace(location)">

8 <input type=button value=刷新 onclick="window.open('自身的文件','_self')">

9 <input type=button value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)>

<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>

10 <form action="自身的文件">

<input type=submit value=刷新>

</form>

11 <a id=a1 href="自身的文件"></a>

<input type=button value=刷新 onclick="a1.click()">