This article is mainly on the JavaScript of the classic code for IE operation introduced, the need for friends can come to the reference, hope to help everyone else
This period of time has been using AJAX technology to do things, so there will be more opportunities to learn JavaScript knowledge. Earlier on the internet to collect some about the JavaScript of IE operation code (specifically where cope, so the source is not added), feeling in the development process is very useful, of course, only applicable to IE,FF will have problems. Now stick it out and share it. Code as follows: 1. The right mouse button will be completely shielded oncontextmenu= "Window.event.returnvalue=false" can be used for table<table Oncontextmenu=return ( False) ><td>no</table> 2. Deselect, prevent replication <bodyonselectstart= "Returnfalse" > 3. No pasting. Onpaste= "Returnfalse" 4 prevent copying oncopy= "Returnfalse" oncut= "Returnfalse;" 5.IE address bar, replace it with your own icon <linkrel= " Shortcuticon "href=" Favicon.ico > 6. You can display your icon in your Favorites folder <linkrel= "Bookmark" href= "Favicon.ico" > 7. Close IME <inputstyle= "ime-mode:disabled" > 8. Always have frames <scriptlanguage= "JavaScript" > <!--if (window ==top) top.location.href= "frames.htm"; --> </script> 9. Prevent being frame <SCRIPTLANGUAGE=javascript> <!--if (top.location!=self.location ) Top.location=self.location; --> </SCRIPT> 10. Web pages will not be saved as <noscript><iframesrc=*.html></iframe></noscripT> 11. View Web page source code <input Type=button value= View Web page source code onclick= "window.location= ' view-source: ' + ' http:// www.jb51.net/"> 12. How to check whether the visitor has used the proxy <%ifrequest.servervariables (" Http_x_forwarded_for ") through the ASP method < > "Then Response.Write" <fontcolor= #FF0000 > You passed the proxy server, "&_" True IP as "&request.servervariables" ("Http_ X_forwarded_for ") endif%> 13. Get the absolute position of the control//javascript <scriptlanguage=" JavaScript "> Functiongetie (E) ... {vart=e.offsettop; varl=e.offsetleft; while (e=e.offsetparent) ... {t+=e.offsettop; l+=e.offsetleft;} Alert ("top=" +t+ "left=" +l); } </script>//vbscript <scriptlanguage= "VBScript" ><!--functiongetie () dimt,l,a,b seta= DOCUMENT.ALL.IMG1 t=document.all.img1.offsettop l=document.all.img1.offsetleft whilea.tagname<> "Body" seta= A.offsetparent t=t+a.offsettop l=l+a.offsetleft Wend MsgBox "Top=" &T&CHR (& "left=" &l,64, "get position of control" Endfunction--> </script> 14. The cursor is the last <scriptlanguage= "JavaScript" at the end of text box text > FUNCTIONCC () ... {vare=event.srcelement varr=e.createtextrange (); R.movestart (' character ', e.value.length); R.collapse (true); R.select (); } </script> <inputtype=textname=text1value= "123" onfocus= "CC ()" > 15. Determine the source of the previous page asp: Request.ServerVariables ("Http_referer") javascript:document.referrer 16. Minimize, maximize, close windows <objectid= Hh1classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" > <paramname= "Command" value= "Minimize" ></ object> <objectid=hh2classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" > <paramname= "Command" value = "Maximize" ></object> <objectid=hh3classid= "Clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" > < Paramname= "Command" value= "close" ></OBJECT> <inputtype=buttonvalue= minimize onclick=hh1. Click () > <inputtype=buttonvalue= maximize ONCLICK=HH2. Click () > <inputtype=buttonvalue= closes Onclick=hh3. Click () > This example applies to IE 17. <% ' defines some constant constadopenforwardonly=0 ' cursors that define database connections to navigate only records forward, not paging, Recordset, BookMark ConstadopenkeyseT=1 ' keyset cursors, changes made to records by other users will be reflected in the recordset, but other users adding or deleting records will not be reflected in the recordset. Support paging, Recordset, BookMark constadopendynamic=2 ' Dynamic cursors are the most powerful, but also the most expensive sources. User changes to the record, add or delete records will be reflected in the recordset. Supports full feature browsing (not supported by Access). Constadopenstatic=3 ' static cursor, just a snapshot of the data, user changes to the record said, add or delete records are not reflected in the recordset. Supports moving forward or backward constadlockreadonly=1 ' lock type, default, read-only, can't make any changes constadlockpessimistic=2 ' when editing immediately lock records, the safest way Constadlockoptimistic=3 ' The recordset is locked only when the Update method is invoked, while other previous operations can still change, insert, and delete the current record constadlockbatchoptimistic= 4 ' records will not be locked while editing, while changes, inserts, and deletions are done in batch mode constadcmdtext=&h0001 constadcmdtable=&h0002%> 18. Web pages will not be cached HTM Web page < metahttp-equiv= "Pragma" content= "No-cache" > <metahttp-equiv= "Cache-control" content= "No-cache", Must-revalidate "> <metahttp-equiv=" Expires "content=" WED,26FEB199708:21:57GMT "> or <metahttp-equiv=" Expires "content=" 0 "> ASP page response.expires=-1 Response.expiresabsolute=now ()-1 response.cachecontrol=" No-cache " PHP page Header (" Expires:mon,26jul199705:00:00gmt "); Header ("Cache-control:no-cache,must-revalidate"); Header ("Pragma:no-cache"); 19. Check that a string of strings is composed entirely of numbers <scriptlanguage= "javascript" ><!--functionchecknum (str) {returnstr.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 the character if (/[^-ÿ]/g.test (s)) alert ("contains Chinese characters"); Elsealert ("all characters"); 22.TEXTAREA Adaptive lines of text number <textarearows=1 name=s1 cols=27 onpropertychange= "this.style.posheight= This.scrollheight "> </textarea> 23. Date minus days equals second date <scriptlanguage=javascript> FUNCTIONCC (DD, Dadd) {//Can be combined with error handling vara=newdate (DD) a=a.valueof () a=a-dadd*24*60*60*1000 a=newdate (a) alert (a.getfullyear () + "year" + ( A.getmonth () +1) + "month" +a.getdate () + "Day")} cc ("12/23/2002", 2) </script> 24. Which Radio is selected <HTML>< Scriptlanguage= "VBScript" > Functioncheckme () foreachobinradio1 Ifob.checkedthenwindow.alertob.value Next Endfunction </script><BODY> <input name= "Radio1" type= "Radio" value= "style" checked>style <input name= "Radio1" type= "Radio" value= "barcode" >barcode <input "button" type= "Check" Onclick= "Checkme ()" > </BODY></HTML> 25. Get the Request.ServerVariables ("") Collection Response.Write The URL of this page <TABLEborder=1><!--TABLEHEADER--><TR><TD><B>VARIABLES</B></TD><TD ><B>value</B></TD></TR> "Foreachobinrequest.servervariables Response.Write" <TR> <TD> "&ob&" </TD><TD> "&request.servervariables (OB) &" </TD></TR> " Next Response.Write "</TABLE>" 26. Native Ip<%=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.scripttimeout% > This file path <%=server.mappath (Request.ServerVariables ("Script_name"))%> Server CPU Number <%=request.servervariables ("number_of_processors")%> Server Interpreter engine <%=ScriptEngine& "/" & ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion & ". & Scriptenginebuildversion%> Server operating system <%=request.servervariables ("OS")%> 27.ENTER key allows the cursor to move to the next input box <input onkeydown= "If" (event.keycode==13) Event.keycode=9 "> 28. Detect the link speed of a website: Add the following code to <body> area: <scriptlanguage=javascript> tim=1 SetInterval ("tim++", MB) b=1 Varautourl=newarray () autourl[1]= "< src=" Pic/url.gif "Align=absmiddle border=0> Www.njcatv.net "autourl[2]=" javacool.3322.net "autourl[3]=" < src= "Pic/url.gif" Align=absmiddle border=0> www.sina.com.cn "autourl[4]=" www.nuaa.edu.cn "autourl[5]=" < src= "Pic/url.gif" Align=absmiddle border=0> Www.cctv.com "Functionbutt () {document.write (" <formname=autof> ") for (vari=1;i<autourl.length;i++) document.write ("<inputtype=textname=txt" +i+ "size=10value= test ... >=" <inputtype=textname=url "+i+" size=40>= "<inputtype=buttonvalue=goonclick=window.open (this.form.url" +i+ ". Value) ><br/>") document.write ("<inputtype=submitvalue= refresh ></form>")} Butt () Functionauto (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++} functionrun () {for (vari=1;i<autourl.length;i++) document.write ("<imgsrc=http://" +autourl[ i]+ "/" +math.random () + "Width=1height=1onerror=auto" (' < src= ' pic/url.gif "Align=absmiddle border=0>http://"; autourl[i]+ "') >")} run () </script> 29. Various styles of CURSOR Auto: Standard cursor default: Standard arrow hand: Hand cursor wait: Waiting cursor TEXT:I cursor Vertical-text: Horizontal i-cursor No-drop: Non-drag cursor not-allowed: Invalid cursor help:? Assist cursor All-scroll: Triangle Direction move: Mobile label Crosshair: Cross Mark E-resize N-resize nw-resize w-resize s-resize se-resize sw-resize 1. No cache locally, automatically refresh every time response.expires=0 Response.AddHeader " Pragma "," No-cache "Response.AddHeader" Cache-control "," Private " 2. Modify contenttype and download GIF formats <% funcTiondl (f,n) onerrorresumenext sets=createobject ("ADODB.stream") s.mode=3 s.type=1 s.open s.LoadFromFile ( Server.MapPath (f)) Iferr.number>0then response.writeerr.number& ":" &err.description Else Response.contenttype= "Application/x-gzip" Response.AddHeader "content-disposition:", "Attachment;filename=" &n Response.BinaryWrite (S.read (s.size)) endif endfunction calldl ("012922501.gif", "T1.gif")%> 19. Check that a string of strings is all composed of numbers <scriptlanguage= "javascript" ><!--functionchecknum (str) ... {return!/d/.test (str)} 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 also need to know Window.screentop,window.screenleft 21. How to determine if a Chinese character if (Escape (str) is included. IndexOf (" %u ")!=-1 alert (" contains Chinese characters "); Elsealert ("all characters"); 22.TEXTAREA The number of adaptive lines of text can be ie5.5+ with overflow-y:visible <textarearows=1name=s1cols=27style= "Overflow-y: Visible "> </textarea&Gt 23. Date minus days equals second date <scriptlanguage=javascript> function cc (DD,DADD) ... {//Can be added error handling Vard=newdate (Dd.replace ("-", "/")) D.setdate (D.getdate () +dadd) alert (d.getfullyear () + "year" + (D.getmonth) +1) + "month" +d.getdate () + "Day")} cc ("2002-2-28", 2) </script>