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. Unselect and prevent copying
<body onselectstart="return false"> |
3. No pasting is allowed
onpaste="return false" |
4. Prevent copying
oncopy="return false;" oncut="return false;" |
5. Change to your own icon in front of the IE address bar
<link rel="Shortcut Icon" href="favicon.ico"> |
6. You can display your icon in your favorites
<link rel="Bookmark" href="favicon.ico"> |
7. Turn off the input method
<input style="ime-mode:disabled"> |
8. Always carry a frame
<script language="JavaScript"> <!-- if (window == top)top.location.href = "frames.htm"; //frames.htm is the frame web page // --> </script> |
9. Prevent frames from being
<SCRIPT LANGUAGE=JAVASCRIPT> <!-- if (top.location != self.location)top.location=self.location; // --> </SCRIPT> |
10. The web page will not be saved as
<noscript> <*** src="/*.html>"; </***> </noscript> |
11. View the web page source code
<input type=button value="/View the web source code onclick="window.location = "view-source:"+ "http://www.chinaz.com""> |
12. Confirm when deletion
<a href=""javascript :if(confirm("Do you really 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 box
<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
javascript: document.referrer |
16. Minimize, maximize, close windows
<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 applies to IE |
17. Block function keys Shift, Alt, Ctrl
<script> function look(){ if(event.shiftKey) alert("Shift key is prohibited!"); //Can be replaced with ALT CTRL } document.onkeydown=look; </script> |
18. The web page 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 have no concave and convex feeling?
<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. The difference between <div> <span>& <layer>?
<div>(division) is used to define large segments of page elements, which will cause a line transfer <span> is used to define elements in the same line. The only difference between them and <div> is that they do not generate a line transfer. <layer> is a tag of ns, ie does not support it, equivalent to <div> |
21. Let the pop-up window always be on the top:
<body onblur="this.focus();"> |
22. Don’t scroll bars?
Let the vertical bar not:
<body style="overflow:scroll;overflow-y:hidden"> </body> |
Let the horizontal bar not:
<body style="overflow:scroll;overflow-x:hidden"> </body> |
Remove both? It's easier
<body scroll="no"> </body> |
23. How to remove the dotted lines around the picture after clicking on the picture link?
<a href="#" onFocus="this.blur()"> <img src="/logo.jpg" border=0> </a> |
24. Email processing submission form
<form name="form1" method="post" action=mailto:****@***.com enctype="text/plain"> <input type=submit> </form> |
25. How to write in the code of refreshing the parent window in the open child window?
window.opener.location.reload() |
26. How to set the size of the page to open
<body onload="top.resizeTo(300,200);"> |
The location where the page is opened
<body onload="top.moveBy(300,200);"> |
27. How to add a background picture that is not full on the page, and the background picture remains unmoved when pulling the page
<STYLE> Body {background-image:url(/logo.gif); background-repeat:no-repeat; background-position:center;background-attachment: fixed} </STYLE> |
28. 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> |
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. How many lines of TEXTAREA adaptive text
<textarea rows=1 name=s1 cols=27 onpropertychange ="this.style.posHeight=this.scrollHeight"> </textarea> |
32. Date minus days equal to the second date
<script language=Javascript> function cc(dd,dadd) { //Error processing 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> |