当前位置:中国站长下载文章中心网页编程ASP编程 → ASP编程中15个非常有用的例子

ASP编程中15个非常有用的例子

减小字体 增大字体 作者:jola  来源:太平洋  发布时间:2008-9-1 17:37:18

1.如何用Asp判断你的网站的虚拟物理路径

答:使用Mappath方法

以下为引用的内容:
       <p align="center"><font size="4" face="Arial"><b>
  The Physical path to this virtual website is:
  </b></font>
  <font color="#FF0000" size="6" face="Arial">
  <%= Server.MapPath("\")%>
  </font></p>

2.我如何知道使用者所用的浏览器?

答:使用the Request object方法

以下为引用的内容:
      strBrowser=Request.ServerVariables("HTTP_USER_AGENT")
  If Instr(strBrowser,"MSIE") <> 0 Then
  Response.redirect("ForMSIEOnly.htm")
  Else
  Response.redirect("ForAll.htm")
  End If

3.如何计算每天的平均反复访问人数

答:解决方法

以下为引用的内容:
       <% startdate=DateDiff("d",Now,"01/01/1990")

  if strdate<0 then startdate=startdate*-1

  avgvpd=Int((usercnt)/startdate) %>

显示结果

        <% response.write(avgvpd) %>

  that is it.this page have been viewed since November 10,1998

4.如何显示随机图象

以下为引用的内容:
  〈% dim p,ppic,dpic

  ppic=12

  randomize

  p=Int((ppic*rnd)+1)

  dpic="graphix/randompics/"&p&".gif"

  %>

显示

〈img src="<%=dpic%>>">

5.如何回到先前的页面

 答:

以下为引用的内容:

<a href="<%=request.serverVariables("Http_REFERER")%>">preivous page</a>

 或用图片如

<img src=http://www.chinaz.com/Program/Asp/"arrowback.gif" alt="<%=request.serverVariables("HTTP_REFERER")%>">