关闭浏览器

dr_lou 2007-05-15 11:57:33

<script language="javascript">
function window.onbeforeunload() {
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
{
window.event.returnValue="确定要退出本页吗?";
}else {
alert("你在刷新")
}
}
</script>
无效

我觉得跟在本页用了框架有关
谁能解决一下。

unload() 和 window.onbeforeunload()刷新也会执行的,就不要发这样的答案了
...全文
255 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
meizz 2007-05-15
  • 打赏
  • 举报
回复
<script language="javascript">
window.onbeforeunload = function() //author: meizz
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
window.event.returnValue = ""; //这里可以放置你想做的操作代码
}
}
</script>
wasuka 2007-05-15
  • 打赏
  • 举报
回复
<script language="javascript">
window.onbeforeunload = function()
{
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
{
window.event.returnValue="确定要退出本页吗?";
}else {
alert("你在刷新")
}
}
</script>
dr_lou 2007-05-15
  • 打赏
  • 举报
回复
meizz测试有效 不过通过文件-〉关闭没法响应
wasuka测试无效 仍然谢谢

马上揭帖

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧