正文

如何捕捉窗口的前进、后退、刷新、停止、关闭、移动事件?_javascript_2007-01-29 09:49:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/Csharpsky/22950.html

分享到:

停止有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("窗口关闭!")elsealert("窗口刷新!")}</script></body> 答8:移动窗口 <body><script>var leftpos,toppos;window.onload=function(){leftpos=window.screenLefttoppos=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()">

阅读(5026) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册