惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 叶小钗
博客园 - 聂微东
U
Unit 42
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
IT之家
IT之家
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)

博客园 - 登峰

VS2010 工具箱装载出错 将用户导入到membership 网络和笔记本 用live writer写博客 上海招聘.net程序员 Virtual Machine--Vmware(2) Virtual Machine -- VmWare(1) 代码自动生成操作 - 登峰 - 博客园 病毒惹的祸 一道受用终身的测试题 慎用优化工具 一个简单的存储过程代码生成器 DataGrid的Bug? 哪个是最好的ORM C#设计模式---概述篇 还原master数据库 Sql Server实用操作小技巧集合(转载) .net 程序发生了一个不可捕获的异常 n取的r的组合数问题
javascript写计数器 - 登峰 - 博客园
登峰 · 2007-05-09 · via 博客园 - 登峰

<script   language   =   "vbscript"   runat   =   "server">   
  sub   application_onstart   
          '取的计数文件的真实路径   
          countfile=server.mappath("count.txt")   
          '创建文件系统对象实例   
          set   myfso   =   server.createobject("scripting.filesystemobject")   
          '若计数文件不存在   
  if   not   myfso.fileexists(countfile)   then   
                  '创建该文件及取得textstream对象实例   
  set   mytextstream   =   myfso.createtextfile(countfile,   True)   
  application.lock   
  application("online")   =   0   
  application("counter")   =   0   
  application.unlock   
  '将计数值写入文件     
  mytextstream.writeline(cstr(application("counter")))   
  else   
                  '以只读的方式打开   
                  set   mytextstream   =   myfso.opentextfile(countfile,1,false)   
                  '读一行,并将值赋给计数变量   
                  application("counter")   =   mytextstream.readline   
  end   if   
        mytextstream.close   
        set   myfso   =   nothing   
  end   sub   
  sub   session_onstart   
          session.timeout   =   1   
          countfile   =   server.mappath("count.txt")   
          set   myfso   =   server.createobject("scripting.filesystemobject")   
          application.lock   
          application("online")   =   application("online")+1   
          application("counter")   =   application("counter")+1   
          application.unlock   
          '以写方式打开文件   
          set   mytextstream   =   myfso.opentextfile(countfile,2,false)   
          '以写行的方式将数据写入文件   
          mytextstream.writeline(cstr(application("counter")))   
          mytextstream.close   
          set   myfso   =   nothing   
  end   sub   
  sub   session_onend   
          application.lock   
          application("online")   =   application("online")-1   
          application.unlock   
  end   sub   
  </script>                                 
  <html>   
  <head>   
  <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
  <title>计数器例子</title>   
  </head>   
  <body>   
  <div   align="center">您是本站第<font   color="#FF0000"><%=application("counter")%></font>位贵宾!     
  </div>   
  </body>   
  </html>