停止有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>
移动窗口<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>
To bencalie(Bencalie): 你的刷新还是关闭里怎么写死其宽度(clientX)呀?? <script language=javascript> function window.onbeforeunload() { if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey){ window.event.returnValue="确定要退出本页吗?"; } </script>
To meizz(梅花雨):因为你给这段如果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>
<script>
document.body.onbeforeunload=aa;
function aa(){
if(event.clientY<0&&event.clientX>760||event.altKey)
alert("窗口关闭!")
else
alert("窗口刷新!")
}
</script>
</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>
你的刷新还是关闭里怎么写死其宽度(clientX)呀??
<script language=javascript>
function window.onbeforeunload()
{
if (event.clientX>document.body.clientWidth && event.clientY<0||event.altKey){
window.event.returnValue="确定要退出本页吗?";
}
</script>
所以有些功能在其它语言中可以实现,而在javascript中是永远无法实现的。
但试我手工点击后就可以刷新,程序如下:
1window.reload();
2 openr.location.replace();
3 window.refresh();
4 window.location()
这几种方式都试验过了,还是不行,有没有解决办法?
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()">