1. The right mouse button will be completely blocked
oncontextmenu="window.event.returnValue=false" |
<table border oncontextmenu=return(false)> <td>no </table> Can be used for Table |
2. Deselect and prevent copying
<body onselectstart="return false"> |
3. Pasting is not allowed
onpaste="return false" |
4. Prevent copying
oncopy="return false;" oncut="return false;" |
5. Change the IE address bar to your own icon
<link rel="Shortcut Icon" href="favicon.ico"> |
6. Your icon can be displayed in favorites
<link rel="Bookmark" href="favicon.ico"> |
7. Close input method
<input style="ime-mode:disabled"> |
8. Always carry a framework
<script language="JavaScript"> <!-- if (window == top)top.location.href = "frames.htm"; //frames.htm is a frame web page // --> </script> |
9. Prevent being framed
<SCRIPT LANGUAGE=JAVASCRIPT> <!-- if (top.location != self.location)top.location=self.location; // --> </SCRIPT> |
10. Web pages will not be saved as
<noscript> <*** src="/*.html>"; </***> </noscript> |
11. View the source code of the web page
<input type=button value="/View web page source code onclick="window.location = "view-source:"+ "http://www.chinaz.com""> |
12. Confirm when deleting
<a href=""javascript :if(confirm("Are you sure you want to delete?"))location="boos.asp?&areyou=delete&page=1"">Delete</a> |
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="&t&chr(13)&"left="&l,64,"Get the position of the control" end function --> </script> |
14. The cursor is stopped at the end of the text in the text box
<script language="javascript"> functioncc() { 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
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="/minimize onclick=hh1.Click()> <input type=button value="/blog/maximize onclick=hh2.Click()> <input type=button value=Close onclick=hh3.Click()> This example is for IE |
17. Shield function keys Shift, Alt, Ctrl
<script> function look(){ if(event.shiftKey) alert("Prohibit pressing the Shift key!"); //Can be replaced with ALT CTRL } document.onkeydown=look; </script> |
18. Web pages will not be cached
<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"> |
19. How to make the form less concave and convex?
<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> |
20. What is the difference between <div> <span>& <layer>?
<div>(division) is used to define large sections of page elements, which will cause line breaks. <span> is used to define elements within the same line. The only difference from <div> is that it does not cause line breaks. <layer> is a tag of ns, which is not supported by ie. It is equivalent to <div> |
21. Make the pop-up window always on top:
<body onblur="this.focus();"> |
22. No scroll bars?
Let there be no vertical bars:
<body style="overflow:scroll;overflow-y:hidden"> </body> |
Leave the bars blank:
<body style="overflow:scroll;overflow-x:hidden"> </body> |
Remove both? simpler
<body scroll="no"> </body> |
23. How to remove the dotted line around the image after clicking on the image link?
<a href="#" onFocus="this.blur()"> <img src="/logo.jpg" border=0> </a> |
24. Email Processing Submit Form
<form name="form1" method="post" action=mailto:****@***.com enctype="text/plain"> <input type=submit> </form> |
25. How to write the code to refresh the parent window in the opened child window?
window.opener.location.reload() |
26.How to set the size of the opened page
<body onload="top.resizeTo(300,200);"> |
Open page location
<body onload="top.moveBy(300,200);"> |
27. How to add a non-full background image to the page so that the background image does not move when the page is pulled.
<STYLE> body {background-image:url(/logo.gif); background-repeat:no-repeat; background-position:center;background-attachment: fixed} </STYLE> |
28. Check whether a string consists entirely of numbers
<script language="Javascript"> <!-- function checkNum(str){return str.match(//D/)==null} alert(checkNum("1232142141")) alert(checkNum("123214214a1")) // --> </script> |
29. Get the size of a window
document.body.clientWidth; document.body.clientHeight |
30. How to determine whether it is a character
if (/[^/x00-/xff]/g.test(s)) alert("Contains Chinese characters"); else alert("all characters"); |
31.The number of TEXTAREA adaptive text lines
<textarea rows=1 name=s1 cols=27 onpropertychange ="this.style.posHeight=this.scrollHeight"> </textarea> |
32. Date minus number of days equals second date
<script language=Javascript> functioncc(dd,dadd) { //Error handling can be added var a = new Date(dd) a = a.valueOf() a = a - dadd * 24 * 60 * 60 * 1000 a = new Date(a) alert(a.getFullYear() + "Year" + (a.getMonth() + 1) + "Month" + a.getDate() + "Day") } cc("12/23/2002",2) </script> |