var global = 0
if(global >0)
alert("页面未刷新")
else
global++
当页面加载时,即把全局变量修改值。
//check for Navigation Timing API support
if (window.performance) {
console.info("window.performance works fine on this browser")
}
if (performance.navigation.type == 1) {
console.info( "This page is reloaded" )
location.hash='/app/homepage'
} else {
console.info( "This page is not reloaded")
}
扩展资料
判断一个网页是刷新还是关闭
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>新建网页 1</title>
</head>
<body οnunlοad=fclose() οnlοad=fload() οnbefοreunlοad=bfunload()>
<script>
var s = "test"
function fclose()
{
if(s=="no")
alert('unload me!='+s+'这是刷新页面!')
else
alert('这是关闭页面')
}
function fload()
{
alert("load me!="+s)
}
function bfunload()
{
s = "no"
}
</script>
</body>
</html>