L@_@K
<!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>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
<script type="text/javascript">
<!--
var dStart = new Date();
window.onbeforeunload = function()
{
var dEnd = new Date();
if ((dEnd-dStart) < 2000)
{
alert("请稍后刷新页面!");
return false;
}
};
//-->
</script>
</head>
<body>
<script type="text/javascript">
<!--
document.write(new Date());
//-->
</script>
</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>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
<script type="text/javascript">
<!--
var dStart = new Date();
window.onbeforeunload = function()
{
var dEnd = new Date();
if ((dEnd-dStart) < 2000)
{
alert("请稍后刷新页面!");
return false;
}
};
//-->
</script>
</head>
<body>
<script type="text/javascript">
<!--
document.write(new Date());
//-->
</script>
</body>
</html>
2、Maxthon下强制刷新代码就无效了。
3、IE和Firefox下连关闭页面都会弹出两次窗口。
就算取消代码中的alert也还有浏览器的confirm。
在<head></head>之间加入
<script>
//捕获键盘事件
function keyDown(e) {
if (event.keyCode==116){
event.keyCode=0;
event.returnValue=false;
}
}
document.onkeydown = keyDown
</script>