判断浏览器关闭还是刷新:
onclick方法也可以这样写:
<html>
<head>
<script type="text/javascript">
var num=0;
window.onbeforeunload=function(){
if(num==0){
window.location.href="<%=basePath%>login.do";
}
num=0;
};
function cl(event) {
if(event.keyCode==116){
num++;
}
}
</script>
</head>
<body style="text-align: center;height: 100%;" onkeydown="cl(event)">
index
</body>
</html>
onclick方法也可以这样写:
window.document.onkeydown = disableRefresh;
function disableRefresh(evt){
alert(evt.keyCode);
};