关于关闭网页弹出提示框的问题。 昨天问了这个问题,但是后来试了下,用onbeforeunload并不行。因为用onbeforeunload的话,刷新这个页面,也有同样的提示框弹出。请哪位高手再教我下,怎么让关闭这个网页的时候,弹出个提示窗口啊?谢谢了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <SCRIPT LANGUAGE="JavaScript"><!--function window.onbeforeunload() { if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey) { window.event.returnValue="确定要关闭此页吗?"; }else { ////刷新进入这里 }}//--></SCRIPT>上面的代码不行吗?如果不可以的话,浏览http://www.cssrain.cn/article.asp?id=681 <html> <script>function logout(){ if (confirm('是否退出?...')) { return true; } else { return false; } }</script> <head><title>index</title></head> <body onbeforeunload="return logout()"> </body></html> 刚才看错了......你看下下面的,再自己改成你要的吧.<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>只在关闭窗口的时候提示,刷新的时候不提示</title><script for=window event=onbeforeunload>if(event.clientX>document.body.clientWidth){ if (confirm('是否退出?...')) { return true; } else { return false; } }</script></head><body></body></html> 如果把那个JAVASCRIPT改成下面的就只有一个提示框了:<script for=window event=onbeforeunload> if(event.clientX>document.body.clientWidth) { window.event.returnValue = '不保存数据了吗?'; }</script> element的用法 jfreechart的chartpanel生成Image对象的问题 关于super 链表实现目录管理 JDBC 的 URL 问题 如何获得hashtable里值的类型?如字符,日期,数值型 聊天程序发送信息和接收信息问题,解决再加分 散分 日期时间 该由哪个变量类型保存? r Re:数字问题 怎么让一个对象一直存活,不被垃圾收回机制回收?不用 static 声明类 或 static 声明变量。
<!--
function window.onbeforeunload()
{
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
{
window.event.returnValue="确定要关闭此页吗?";
}else
{
////刷新进入这里
}
}
//-->
</SCRIPT>
上面的代码不行吗?
如果不可以的话,浏览http://www.cssrain.cn/article.asp?id=681
<script>
function logout()
{
if (confirm('是否退出?...'))
{
return true;
}
else
{
return false;
}
}
</script> <head><title>index</title></head>
<body onbeforeunload="return logout()">
</body>
</html>
你看下下面的,再自己改成你要的吧.<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>只在关闭窗口的时候提示,刷新的时候不提示</title>
<script for=window event=onbeforeunload>
if(event.clientX>document.body.clientWidth)
{
if (confirm('是否退出?...'))
{
return true;
}
else
{
return false;
} }
</script>
</head><body></body></html>
<script for=window event=onbeforeunload>
if(event.clientX>document.body.clientWidth)
{
window.event.returnValue = '不保存数据了吗?';
}
</script>