<a href="#" onclick="countNumber()">点击</a>
<script type="text/javascript">
if(!localStorage.countAll){
localStorage.countAll = 0
}
document.getElementById('countspan').innerHTML = localStorage.countAll
function countNumber(){
localStorage.countAll++
document.getElementById('countspan').innerHTML = localStorage.countAll
}
</script>
支持html5的浏览器都能用。
var k=0window.onload = function(){
setInterval(function(){k=k+10},200)
}
function otherFun(){
alert(k)
}
把K设置为全局的,其他地方想用就用