Some tips on JavaScript (reprinted)
Reprint address: http://hdy00.spaces.live.com /? _ C11_blogpart_pagedir = next & _ c11_blogpart_handle = CNS! 9259ab600c591772! 251 & _ c11_blogpart_blogpart = blogview & _ c = blogpart
1. oncontextmenu = "window. event. returnvalue = false" will be completely blocked by right-clicking <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.
7. <input style = "ime-mode: Disabled"> disable the input method.
8. Always carry the framework <script language = "JavaScript"> <! -- If (window = Top) top. Location. href = "frames.htm"; // frames.htm indicates the framework webpage. // --> </SCRIPT>
9. Prevent frame <script language = JavaScript> <! -- If (top. location! = Self. Location) top. Location = self. Location; // --> </SCRIPT>
10. <NoScript> <IFRAME src = *. html> </iframe> </NoScript> webpages cannot be saved
11. <input type = button value = view the webpage source code onclick = "window. Location =/'view-Source:/'+/'HTTP: // www.csdn.net/'">
12. how to use ASP to check whether the visitor has used a proxy <% 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. // JavaScript <script language = "JavaScript"> 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. tagname <> "body" set a =. offsetparent T = T +. offsettop L = L +. offsetleft Wend msgbox "Top =" & T & CHR (13) & "Left =" & L, 64, "Get control location" end function --> </SCRIPT>
14. the cursor is the last <script language = "JavaScript"> 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") Java Script: 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. <%/'defines some constant const adopenforwardonly = 0/' for database connection. The cursor only browses records forward. It does not support paging, recordset, Bookmark const adopenkeyset = 1, changes made by other users to records will be reflected in the record set, but the addition or deletion of records by other users will not be 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/'static curs', which is only a snapshot of the data. The added or deleted records modified by the user on the record are not reflected in the record set. The const adlockreadonly = 1/'locking type can be moved forward or backward. The default const adlockreadonly type is read-only and cannot be modified. Const adlockpessimistic = 2/'the record is locked immediately when being edited, the safest way is const adlockoptimistic = 3/'. The record set is locked only when the update method is called, other operations earlier than this can still change, insert, and delete the current record. Const adlockbatchoptimistic = 4/'the record will not be locked when being edited, const ad1_text = & h0001 const adcmdtable = & h0002 %>
18. web pages are not cached HTM web pages <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"); H Eader ("cache-control: No-cache, must-revalidate"); header ("Pragma: No-Cache"); how to make the form feel free of attention? <Input type = text style = "border: 1 solid #000000"> or <input type = text style = "border-left: none; border-Right: none; border-top: none; border-bottom: 1 solid #000000 "> </textarea> <div> <span> & <layer>? <Div> (Division) is used to define the page elements of a large segment and produces a transpose <span> to define the elements in the same row, the only difference from <div> is that no transpose line is generated. <layer> is the NS mark, which is not supported by IE. It is equivalent to <div> making the pop-up window always at the top: <body onblur = "this. focus (); "> do not use a scroll bar? Make the vertical bar not: <body style =/'overflow: Scroll; overflow-Y: hidden/'> </body> make the horizontal bar not: <body style =/'overflow: Scroll; overflow-X: hidden/'> </body>? More simply, <body scroll = "no"> </body> how to remove the dotted line around the image after clicking the image link? <A href = "#" onfocus = "this. blur () "> </a> email processing submission form <form name =" form1 "method =" Post "Action =" mailto: ****@***. com "enctype =" text/plain "> <input type = submit> </form>? Window. opener. location. how to set the page size for reload () <body onload = "Top. resizeTo (300,200); "> how to add a background image that is not full? When pulling the page, the background image does not move <HTML>
19. check whether a string is composed of digits. <script language = "JavaScript"> <! -- 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
21. how to determine whether it is a character if (/[^/x00-/xFF]/g. test (s) Alert ("containing Chinese characters"); else alert ("All characters ");
22. Number of textarea adaptive lines <textarea rows = 1 name = S1 Cols = 27 onpropertychange = "This. style. posheight = This. scrollheight"> </textarea>
23. date minus the number of days equals to the second date <script language = JavaScript> function CC (DD, dadd) {// you can add error processing var A = new date (dd) A =. valueof () A = A-dadd * 24*60*60*1000 A = new date (a) Alert (. getfullyear () + "year" + (. getmonth () + 1) + "month" +. getdate () + "day")} CC ("12/23/2002", 2) </SCRIPT>
24. which radio <HTML> <script language = "VBScript"> function checkme () for each ob in radio1 if OB is selected. 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" onclick = "checkme () "> </body>
25. Obtain the request. servervariables ("") set 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 address <% = request. servervariables ("local_addr") %> server port <% = request. servervariables ("server_port") %> server time <% = now %> IIS version <% = request. servervariables "server_software") %> script timeout <% = server. scripttimeout %> file path <% = server. mappath (request. servervariables ("script_name") %> server CPU count <% = request. servervariables ("number_of_processors") %> server interpretation engine <% = scriptengine & "/" & scriptenginemajorversion &". "& scriptengineminorversion &". "& scriptenginebuildversion %> Server Operating System <% = request. servervariables ("OS") %>
27. Press enter to move the cursor to the next input box <input onkeydown = "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 = JavaScript> Tim = 1 setinterval ("Tim ++", 100) B = 1 var autourl = new array () autourl [1] = "www.njcatv.net" autourl [2] = "canonical" 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 + "s Ize = 10 value = testing...> = "<Input type = text name = URL" + I + "size = 40 >=" <input type = button value = go onclick = 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 + "seconds"} B ++} function run () {for (VAR I = 1; I <autourl. length; I ++) document. write ("
29. various styles of cursor Auto: Standard cursor default: Standard arrow hand: Hand-shaped cursor wait: Waiting 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 move: Move crosshair: Cross e-resize N-resize NW-resize w-resize S-resize se-resize Sw-resize