我希望页面加载10次
alert ('hello !!');
怎么得到的?
这是我的代码:
<html>
<head>
<title>my problem !!</title>
<script type="text/javascript">
var i = 0;
myfunc = function () {
if (i++ == 10){
alert ('hello !!');
}
}
window.onload = myfunc;
</script>
</head>
<body>
</body>
</html>
谢谢您的帮助:x
最佳答案
<html>
<script>
var visitCount = localStorage["visitCount"];
visitCount = parseInt(visitCount);
if (!visitCount) {
visitCount = 0;
}
visitCount = visitCount + 1;
if (visitCount >= 10) {
alert("hello!");
visitCount = 0;
}
localStorage["visitCount"] = visitCount;
</script>
<body>
Hi!
</body>
</html>