Some of the code commonly used by ASP beginners
1. Get system time:
<% = NOW ()%>
2. Available in IP:
<% = Request.ServerVariables ("remote_host")%>
3. Get system, browser version:
Window.Document.write ("Version:" Navigator.Appname Navigator.AppVersion "Browser.")
script>
4. Remove the IE mixing bar:
5. Enter the website and jump out of your advertisement:
WINDOW.OPEN ('' http://www.xxxxxx.com'' ,'''' ,''Height=200 ,width=300 ,top=0 ,le=30 ');
// ->
script>
6. Random:
<% randomize%>
<% = (int (RND () * n) 1)%>
N is a changeable number
7. Mixed code:
8. Automatically turn off the webpage:
Settimeout ('' window.close (); '', 1000); // 60 seconds after close
// ->
script>
Automatically shut down after 10 seconds this page, please note the refresh page p>
9. Random background music:
<% randomize%>
You can modify the number, limit the number of calls, I am 60 here.
10. Automatically refresh this page:
Var limit = "0:10"
IF (Document.Images) {
Var parselimit = limited.split (":")
PARSELIMIT = PARSELIMIT [0] * 60 PARSELIMIT [1] * 1
}
Function beginRefresh () {
IF (! Document.Images)
Return
IF (parselimit == 1)
Window.Location.Reload ()
Else {
PARSELIMIT- = 1
Curmin = Math.Floor (Parselimit / 60)
Cursec = PARSELIMIT% 60
IF (Curmin! = 0)
Curtime = CURMIN "Take" CURSEC "after retransmate this page!"
Else
Curtime = CURSEC "After the second, turn on this page!"
WINDOW.STATUS = CURTIME
SetTimeout ("BeginRefresh ()", 1000)
}
}
Window.οnlοad = beginRefresh
File: // ->
script>
11. Access database connection:
<%
Option expedition
DIM Startime, EndTime, Conn, Connstr, DB
Startime = Timer ()
'Change the database name
DB = "DATA / DVBBS5.MDB"
Set conn = server.createObject ("adoDb.connection")
Connstr = "provider = microsoft.jet.Oledb.4.0; data source =" & server.mappath (db)
'If your server uses an older version access driver, use the following connection method.
'Connstr = "Driver = {Microsoft Access Driver (* .mdb)}; dbq =" & Server.mappath (dB)
Conn.open connStr
Function CloseDatabase
Conn.close
Set conn = Nothing
END FUNCTION
%>
12.sql database connection:
<%
Option expedition
DIM Startime, EndTime, Conn, Connstr, DB
Startime = Timer ()
Connstr = "driver = {SQL Server}; server = hudenq-n11t33nb; uid = sa; pwd = xsfeihu; database = dvbbs"
Set conn = server.createObject ("adoDb.connection")
Conn.open connStr
Function CloseDatabase
Conn.close
Set conn = Nothing
END FUNCTION
%>
13. Open the web code with the keyboard:
Function CTlent (EVENTOBJECT)
{
IF ((Event.ctrlKey && Window.Event.Keycode == 13) || (Event.altKey && Window.Event.Keycode == 83))))))
{
WINDOW.OPEN ('URL', '', '')
}
}
script>
Here is Ctrl Enter and Alt s code yourself to check the ASCII code of the keyboard and change it.
14. Let the layer are not covered by the control: