Sort and add to favorites: ASP excellent entriesCode
1. oncontextmenu = "window. event. returnvalue = false" will completely block the right mouse button
<Table border oncontextmenu = return (false)> <TD> NO </table>
2. <body onselectstart = "Return false"> cancel selection to prevent Replication
3. onpaste = "Return false" Do not paste
4. oncopy = "Return false;" oncut = "Return false;" Prevent Replication
5. <LINK rel = "shortcut icon" href = "favicon. ICO"> replace it with your own icon in front of the IE Address Bar
6. <LINK rel = "bookmark" href = "favicon. ICO"> your Icons can be displayed in favorites.
How to set this site as the homepage
You may have noticed that many websites now have such a link "set this site as the homepage" (the homepage here refers to the browser's start page ).
In addition to large ISP and ICP websites, some personal homepages also offer this "service" to attract users. How does one implement this function? Let me help you to analyze:
Click the hyperlink to download a URL named lspace. reg file. After downloading it, double-click it to modify your registry. Then, when you open the browser again, the start page changes. (As soon as I heard about the Registry Modification, many netizens compared "break" to see if windows was broken .)
Don't be afraid. Let's open lspace. Reg (you can open it with the most common notepad) and find the following content:
Regedit4
[HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ main]
"Start page" = "http://www.aygame.com /";;
[HKEY_CURRENT_USER \ Software \ Netscape Navigator \ main] "home page" = "http://www.aygame.com /";;
It turns out that there are only two items. The first setting is IE's star page, and the second setting is NC's home page :). The URL that follows is the URL of your homepage!
7. <input style = "ime-modeisabled"> disable the Input Method
8. Always carry the framework
<Script .. Language = "*****"> <! --
If (window = Top) top. Location. href = "frames.htm"; // frames.htm is the frame webpage.
// --> </Script...>
9. Prevent Frame
<Script... language = *****> <! --
If (top. Location & nbsp ;! = Self. Location) top. Location = self. location;
// --> </Script...>
10. <NoScript...> <IFRAME src = *. html> </iframe> </NoScript...> the webpage cannot be saved
11. <input type = button value = view web pageSource code
On.. Click = "window. Location & nbsp; = 'view-Source: '+ 'HTTP: // www.csdn.net/'";>
12. How to use ASP to check whether the visitor has used an agent?
<% If request. servervariables ("http_x_forwarded_for") <> "then
Response. Write "<font color = # ff0000> you have passed the proxy server ,"&_
"The real IP address is" & request. servervariables ("http_x_forwarded_for ")
End if
%>
13. Obtain the absolute position of the control
//****
<Script .. Language = "*****">
Function .. getie (e ){
Var.. t = E. offsettop;
Var.. l = E. offsetleft;
While (E = E. offsetparent ){
T + = E. offsettop;
L + = E. offsetleft;
}
Alert ("Top =" + T + "\ nleft =" + l );
}
</Script...>
// VBScript ..
<Script... language = "VBScript..."> <! --
Function .. getie ()
Dim t, L, A, B
Set a = Document. All. img1
T = Document. All. img1.offsettop
L = Document. All. img1.offsetleft
While a. tagname <> "body"
Set a = A. offsetparent
T = T + A. offsettop
L = L + A. offsetleft
Wend
Msgbox "Top =" & T & CHR (13) & "Left =" & L, 64, "Get control position"
End function ..
--> </Script...>
14. The cursor stops at the end of the text box.
<Script .. Language = "*****">
Function .. CC ()
{
Var.. E = event. srcelement;
Var.. r = E. createTextRange ();
R. movestart ('character ', E. value. Length );
R. Collapse (true );
R. Select ();
}
</Script...>
<Input type = text name = text1 value = "123" onfocus = "CC ()">
15. determine the source of the previous page
ASP:
Request. servervariables ("http_referer ")
****:
Document. referrer
16. Minimize, maximize, and close the window
<Object ID = HH1 classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "minimize"> </Object>
<Object ID = HH2 classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "maximize"> </Object>
<Object ID = hh3 classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "command" value = "close"> </Object>
<Input type = button value = minimized onclick = hh1.click ()>
<Input type = button value = maximized onclick = hh2.click ()>
<Input type = button value = Disable onclick = hh3.click ()>
This example applies to IE
17.
<%
'Define some constants for database connection
Const adopenforwardonly = 0' the cursor only browses records forward. pagination, recordset, and bookmark are not supported.
Const adopenkeyset = 1' indicates the keyset cursor. modifications made by other users to the record are reflected in the record set. However, adding or deleting records by other users is not reflected in the record set. Supports paging, recordset, and bookmark const adopendynamic = 2' dynamic cursors, but consumes the most resources. The added or deleted records modified by the user on the record description will be reflected in the record set. Supports full-featured browsing (access is not supported ).
Const adopenstatic = 3' the static cursor is only a snapshot of the data. The changes you make to the record description, adding or deleting records, will not be reflected in the record set. Supports moving forward or backward
Const adlockreadonly = 1' lock type, default, read-only, cannot be modified
Const adlockpessimistic = 2' lock the record immediately when editing, the safest way
Const adlockoptimistic = 3' the record set is locked only when the update method is called, and other operations before this can still change, insert, and delete the current record.
Const adlockbatchoptimistic = 4' records are not locked when being edited, but changes, inserts, and deletes are completed in the batch processing mode.
Const ad1_text = & h0001
Const adcmdtable = & h0002
%>
18. The webpage will not be cached
Htm webpage
<Meta .. HTTP-EQUIV = "Pragma" content = "no-Cache">
<Meta .. HTTP-EQUIV = "cache-control" content = "no-cache, must-revalidate">
<Meta .. HTTP-EQUIV = "expires" content = "wed, 26 Feb 1997 08:21:57 GMT">
Or <meta .. HTTP-EQUIV = "expires" content = "0">
ASP Web Page
Response. expires =-1
Response. expiresabsolute = now ()-1
Response. cachecontrol = "no-Cache"
PHP webpage
Header ("expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("cache-control: No-cache, must-revalidate ");
Header ("Pragma: No-Cache ");
19. check whether a string is composed of digits.
<Script language = "*****"> <! --
Function checknum (STR) {return Str. Match (/\ D/) = NULL}
Alert (checknum ("1232142141 "))
Alert (checknum ("123214214a1 "))
// --> </SCRIPT>
20. Get the size of a window
Document. Body. clientwidth, document. Body. clientheight
Document. Body. offsetwidth, document. Body. offsetheight
Sometimes you need to know window. screentop, window. screenleft
21. How can I determine whether it is a character?
If (/[^ \ x00-\ xFF]/g. test (s) Alert ("containing Chinese characters ");
Else alert ("All characters ");
22. Number of lines of textarea adaptive text
<Textarea rows = 1 name = S1 Cols = 27 onpropertychange = "This. style. posheight = This. scrollheight">
</Textarea>
23. The date minus the number of days equals to the second date
<Script... language = ***>
Function .. CC (DD, dadd)
{
// Add error handling.
VaR .. A = new date (dd)
A = A. valueof ()
A = A-dadd * 24x60*60*1000
A = new date ()
Alert (A. getfullyear () + "year" + (A. getmonth () + 1) + "month" + A. getdate () + "day ")
}
CC ("12/23/2002", 2)
</Script...>
From: bbs.77169.com
--------------------------------------------
It is always good to represent justice. Even if you want to do the most humble and shameless thing, you must do it on a high-sounding grounds.
24. Which radio is selected
<HTML> <script... language = "VBScript...">
Function .. checkme ()
For each ob in radio1
If OB. Checked then window. alert OB. Value
Next
End function ..
</Script...> <body>
<Input name = "radio1" type = "radio" value = "style" Checked> Style
<Input name = "radio1" type = "radio" value = "barcode"> Barcode
<Input type = "button" value = "check" on .. click = "checkme ()">
</Body>
25. Obtain the request. servervariables ("") set of the URL on this page.
Response. Write "<Table border = 1> <! -- Table header --> <tr> <TD> <B> variables </B> </TD> <B> value </B> </TD> </ tr>"
For each ob in request. servervariables
Response. write "<tr> <TD>" & ob & "</TD> <TD>" & request. servervariables (OB) & "</TD> </tr>"
Next
Response. Write "</table>"
26.
Local IP address <% = request. servervariables ("remote_addr") %>
Server name <% = request. servervariables ("SERVER_NAME") %>
Server IP <% = request. servervariables ("local_addr") %>
Server port <% = request. servervariables ("server_port") %>
Server time <% = now %>
IIS version <% = request. servervariables "server_software") %>
Script timeout <% = server. script... timeout %>
Path of this file <% = server. mappath (request. servervariables ("script... _ name") %>
Server CPU count <% = request. servervariables ("number_of_processors") %>
Server interpretation engine <% = script .. engine & "/" & script... enginemajorversion & "." & script... engineminorversion & "." & script... enginebuildversion %>
Server Operating System <% = request. servervariables ("OS") %>
27. Press enter to move the cursor to the next input box.
<Input on .. keydown = "If (event. keycode = 13) event. keycode = 9">
28. Check the link speed of a Website:
Add the following code to the <body> area:
<Script... language = ***>
Tim = 1
Setinterval ("Tim + +", 100)
B = 1
VaR .. autourl = new array ()
Autourl [1] = "www.njcatv.net"
Autourl [2] = "javacool.3322.net"
Autourl [3] = "www.sina.com.cn"
Autourl [4] = "www.nuaa.edu.cn"
Autourl [5] = www.cctv.com
Function .. Butt (){
Document. Write ("<form name = autof> ")
For (var.. I = 1; I <autourl. length; I ++)
Document. Write ("<input type = text name = TXT" + I + "size = 10 value = testing...> = "<Input type = text name = URL" + I + "size = 40 >=" <input type = button value = go on .. click = Window. open (this. form. URL "+ I + ". value)> <br/> ")
Document. Write ("<input type = submit value = Refresh> </form> ")
}
Butt ()
Function .. auto (URL ){
Document. Forms [0] ["url" + B]. value = URL
If (TIM> 200)
{Document. Forms [0] ["TXT" + B]. value = "link timeout "}
Else
{Document. Forms [0] ["TXT" + B]. value = "time" + TIM/10 + "second "}
B ++
}
Function .. run () {for (VAR .. I = 1; I <autourl. length; I ++) document. write (" ")}
Run () </script...>
29. Various styles of cursor
Auto: Standard cursor
Default: Standard arrow
Hand: Hand-shaped cursor
Wait: waiting for the cursor
Text: I-shaped cursor
Vertical-text: horizontal I-shaped cursor
No-drop: Do not drag the cursor
Not-allowed: Invalid cursor
Help :? Help cursor
All-scroll: triangle direction indicator
Move: Move mark
Crosshair: Cross logo
E-resize
N-resize
NW-resize
W-resize
S-resize
Se-resize
Sw-resize
30. No local cache, automatically refresh each time
Response. expires = 0
Response. addheader "Pragma", "No-Cache"
Response. addheader "cache-control", "private"
31. Modify contenttype and download GIF and other formats
<%
Function .. DL (F, n)
On Error resume next
Set S = Createobject ("ADODB. Stream ")
S. mode = 3
S. type = 1
S. Open
S. loadfromfile (server. mappath (f ))
If err. Number> 0 then
Response. Write err. Number & ":" & err. descript... ion
Else
Response. contenttype = "application/X-gzip"
Response. addheader "content-Disposition:", "attachment; filename =" & n
Response. binarywrite (S. Read (S. Size ))
End if
End function ..
Call DL ("012922501.gif"," t1.gif ")
%>
32. check whether a string is composed of digits.
<Script .. Language = "*****"> <! --
Function .. checknum (STR) {return! /\ D/. Test (STR )}
Alert (checknum ("1232142141 "))
Alert (checknum ("123214214a1 "))
// --> </Script...>