<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设置为全局的,其他地方想用就用
1、将以下代码加在你需要得位置; 2、在根目录下创建名为count的文件夹,并在里面创建counter.txt文件,文件初始值为0(可更改); 3、将设置好的网页保存为.asp格式; 4、ok 您是第<span class="style2"> <% Const ForReading = 1, ForWriting = 2, ForAppending =3 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 filepath=server.mappath("/count") filename=filepath+"\counter.txt" set fs=createobject("scripting.filesystemobject") if fs.fileexists(filename) then set f=fs.getfile(filename) Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault) s=ts.readline+1 ts.close else fs.createtextfile(filename) set f=fs.getfile(filename) s=1 end if '向counter.txt中写数据 Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault) ts.writeline(cstr(s)) ts.close '显示计数器 s=cstr(s+1000000) s=mid(s,2,8) for I=1 to 8 response.write mid(s,I,1) next %> </span>位访问者