1. How to use ASP to determine the virtual physical path of your website
A: Use the mappath method. < 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. How do I know the browser used by the user?
A: Use the request object method. Strbrowser = request. servervariables ("http_user_agent ")
If instr (strbrowser, "MSIE ") < > 0 then
Response. Redirect ("formsieonly.htm ")
Else
Response. Redirect ("forall.htm ")
End if
3. How to calculate the average number of repeated visits per day<% Startdate= Datediff ("D", now, "01/01/1990 ")
If strdate <0 then startdate= Startdate *-1
Avgvpd= Int (usercnt)/startdate)%>
Display result
<% Response. Write (avgvpd) %>
That is it. This page have been viewed since November 10, 1998
4. How to display random images< % Dim P, PPIC, dpic
PPIC = 12
Randomize
P = Int (PPIC * RND) + 1)
Dpic = "Graphix/randompics /" & P & ". GIF"
% >
Display
< IMG SRC = "<% = Dpic %>" >
5. How to return to the previous page : < A Href = "<% = Request. servervariables (" Http_referer ") % > "> Preivous page < / >
Or use an image, such: < IMG SRC = "Arrowback.gif" ALT = "<% = Request. servervariables (" Http_referer ") % > ">
6. How to Determine the IP address of the other party < % = Request . Servervariables ("remote_addr) % >
7. how to link to an image %@ ages =vbs 0000% >
% response . expires = 0
strimagename =" Graphix/errors/erroriamge.gif "
response. redirect (strimagename)
% >
8. Force password input dialog box
Put this sentence at the beginning of the page<% Response. Status= "401 not authorized"
Response. End
%>
9. How to pass variables from one page to another
A: Use the hidden type to pass variables. < % Form Method = "Post" Action = "Mynextpage. asp" >
< % Each item in request. Form % >
< Input Namee = "<% = Item %>" Type = "Hidden"
Value = "<% = Server. htmlencode (request. Form (item) %>" >
< % Next % >
< /Form >
10. Why am I in ASPProgramWhen msgbox is used, the program fails to say that it has no permission.
A: Because ASP is run on the server, if you can display a dialog box on the server, you have to wait for someone to confirm before your program can continue to run, in general, the server won't be guarded, so Microsoft has to disable this function and tell you (:) haha) that it has no permission. However, the combination of ASP and client scripts can display a dialog box, as follows:
Source: 51js.com