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

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

enet学院

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

答 使用Mappath方法

1<p align="center"><font face="Arial" size="4"><b>   
2  
3The Physical path to this virtual website is:   
4  
5</b></font>
6<font color="#FF0000" face="Arial" size="6">   
7  

= Server.MapPath("")

1  
2</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。如何计算每天的平均反复访问人数

答 解决方法

1 startdate=DateDiff("d",Now,"01/01/1990")   
2  
3if strdate<0 then startdate=startdate*-1   
4  
5avgvpd=Int((usercnt)/startdate) 

显示结果

1 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

1  
25.如何回到先前的页面   
3  
4

<a "="" href=" =request.serverVariables(" http_referer")="">preivous page

1或用图片如:

<img "="" alt=" =request.serverVariables(" http_referer")="" src="arrowback.gif"/>

16.如何确定对方的IP地址   
2  
3答〈%=Request.serverVariables("REMOTE_ADDR)%&gt;   
4  
57。如何链结到一副图片上   
6  

@Languages=vbscript

1  

response.expires=0

strimagename="graphix/errors/erroriamge.gif"

response.redirect(strimagename)

Published At
Categories with Web编程
comments powered by Disqus