我想在火狐的关闭事件调用方法
但现在好像没什么好的解决方法
用
window.onbeforeunload = function() {
alert("关闭");
}这个方法的话只要刷新页面就调用了,保存 删除什么的都调用了
我只想他标签关闭的时候调用怎么写呢
各位大虾指教了
但现在好像没什么好的解决方法
用
window.onbeforeunload = function() {
alert("关闭");
}这个方法的话只要刷新页面就调用了,保存 删除什么的都调用了
我只想他标签关闭的时候调用怎么写呢
各位大虾指教了
alert("关闭");
}
我采取的笨办法是定义一个全局变量bIsRefresh;然后在其他产生刷新的地方(比如:F5键、右键菜单、js的location.reload()等),将之赋值为true。
<script>
bIsRefresh=false;function test(){
bIsRefresh=true;
location.reload();
}
window.onbeforeunload = function(e) {
e=e||window.event;
if (window.bIsRefresh)return;//刷新跳出函数
e.returnValue="关闭??????"
alert("关闭");
}
</script>
<html>
<body>
<p onclick='test()'>刷新测试</p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>绑定函数</title>
<script src="jquery-1.3.2.js"></script>
<script>
$(document).ready(function(){
var length = $("div").length;
// alert(length)
});
</script>
<script>
bIsRefresh=false;
function test(){
bIsRefresh=true;
location.reload();
}
window.onbeforeunload = function(e) {
e=e||window.event;
if (window.bIsRefresh)return;//刷新跳出函数
e.returnValue="关闭??????"
alert("关闭");
}
</script></head><body>
<p onclick='test()'>刷新测试</p>
</body>
</html>
ff下可以 也就是二楼的代码