Common Tips for HTML code

Source: Internet
Author: User

IE JavaScript shortcut key operation1. oncontextmenu="Window.event.returnvalue=false"the right mouse button will be completely shielded<table Border oncontextmenu=return(false) ><td>no</table>Available for table2. <body onselectstart="return False">deselect, prevent copying3. Onpaste="return False"no pasting .4. oncopy="return false;"oncut="return false;"Prevent replication5. <link rel="Shortcut Icon"href=. /.. /.. /"Favicon.ico">switch to your own icon before the IE Address bar6. <link rel="Bookmark"href=. /.. /.. /"Favicon.ico">You can display your icon in the Favorites folder.7. <input style="ime-mode:disabled">Turn off IME8. Always with the frame<script language="JavaScript"><!--if(window = = top) Top.location.href ="frames.htm";//frames.htm for frames page//--></script>9. Prevent the person from being frame<script language=javascript><!--if(top.location! = self.location) top.location=self.location;//--></script>Ten. <noscript><iframe src=. /../*. Html></iframe></noscript> Web pages will not be saved as 11. <input type=button value= View Web page source code onclick= "window.location = ' view-source: ' + 'http://www.csdn.net/' > 12. How to use ASP to check whether the visitor uses proxy <% if Request.ServerVariables ("Http_x_forwarded_for") <> "Then Response.Write" < Font color= #FF0000 > You passed the proxy server, "& _" Real IP is "&request.servervariables (" http_x_forwarded_for ") End If%> 13. Get 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 a.tagname<> "BODY" Set a = A.offsetparent t=t+a.offsettop l=l+a.offsetleft Wend MsgBox "Top=" &AMP;T&AMP;CHR (& "left=" &l,64, "get control position" End Function--></script> 14. The cursor is the last <script language= "JavaScript" > Function cc () {var e = event.srcelement; var r =e.createtextrange () that stops at the text box type; 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") Javascript:document.referrer 16. Minimize, maximize, close 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= minimizes onclick=hh1. Click () > <input Type=button value= maximize ONCLICK=HH2. Click () > <input type=button value= close Onclick=hh3. Click () > This example applies to IE 17. <% ' defines some constants for database connections Const ADOPENFORWARDONLY = 0 ' cursors only forward browsing records, not paging, Recordset, BookMark Const adopenkeyset = 1 ' keyset cursors, other users to the record said The changes you make will be reflected in the recordset, but other users adding or deleting records are not reflected in the recordset. Support for paging, Recordset, BookMark Const adopendynamic = 2 ' dynamic cursorsThe most powerful, but also the most expensive source. Changes that the user makes to the record, add or delete records are reflected in the recordset. Full-featured browsing is supported (access is not supported). The Const adopenstatic = 3 ' static cursor is just a snapshot of the data, and the user modifies the record, adding or deleting records that are not reflected in the recordset. Supports moving forward or backward const ADLOCKREADONLY = 1 ' lock type, default, read-only, cannot make any modifications const adLockPessimistic = 2 ' When editing immediately lock record, the safest way to const ADLOCKOPTIMIS TIC = 3 ' The recordset is locked only when the Update method is called, while other operations in the previous operation can still make changes to the current record, insert and delete Const adLockBatchOptimistic = 4 ' When editing the record is not locked, and the change, Insert and delete are const ADCMDTEXT = &h0001 Const adCmdTable = &h0002%> 18, which is done in batch mode. Web pages will not be cached for HTM pages <meta http-equiv= "pragma" content= "No-cache" > <meta http-equiv= "Cache-control" content= " No-cache, must-revalidate "> <meta http-equiv=" Expires "content=" Wed, "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 page Header (" Expires:mon, 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 numbers <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 if the character if (/[^\x00-\xff]/g.test (s)) alert ("contains Chinese characters"); else alert ("All characters"); 22.TEXTAREA Adaptive number of lines of text <textarea rows=1 name=s1 cols=27 onpropertychange= "This.style.posheight=this.scrollheight" > </textarea> 23. Date minus number of days equals second date <script language=javascript> function cc (DD,DADD) {//can be added with error handling var a = new Date (dd) a = a.valueof () a = A-dadd * * * + * + a = new Date (a) alert (a.getfullyear () + "year" + (A.getmonth () + 1) + "month" + a.getdate () + "Day ")} cc (" 12/23/2002 ", 2) </script> 24. Which radio is selected 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.