1. oncontextmenu="window.event.returnValue=false" will completely block the right mouse button
<table border oncontextmenu=return(false)><td>no</table> can be used in Table
2. <body onselectstart="return false"> Cancel selection and prevent copying
3. onpaste="return false" No pasting allowed
4. oncopy="return false;" oncut="return false;" Prevent copying
5. <link rel="Shortcut Icon" href="favicon.ico "> Replace the IE address bar with your own icon
6. <link rel="Bookmark" href="favicon.ico"> You can display your icon in your favorites
7. <input style="ime-mode:disabled "> Turn off the input method
8. Always bring the frame
<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><iframe src=*.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.pconline.com.cn "">
12. Confirm when deleting
<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 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 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=minimize onclick=hh1.Click()>
<input type=button value=maximize onclick=hh2.Click()>
<input type=button value=Close onclick=hh3.Click()>
This example is suitable 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. Let the pop-up window always be at the top:
<body onblur="this.focus();">
22. Don’t want scroll bars?
Let there be no vertical bars:
<body style="overflow:scroll;overflow-y:hidden">
</body>
To make the horizontal bar disappear:
<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 submission 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 the number of days equals the 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>
33. Which Radio is selected
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.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></HTML>
34. Scripts never go wrong
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>
35. The ENTER key can move the cursor to the next input box
<input onkeydown="if(event.keyCode==13)event.keyCode=9">
36. 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.soAsp.net "
autourl[2]="javacool.3322.net"
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+" size=10 value=Under 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("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1
onerror=auto(" http://"+autourl +"")>")}
run()</script>
37. Various styles of cursor
auto: standard cursor
default: standard arrow
hand: hand cursor
wait: wait for the cursor
text: I-shaped cursor
vertical-text: Horizontal I-shaped cursor
no-drop: the cursor cannot be dragged
not-allowed: Invalid cursor
help:?Help cursor
all-scroll: triangular direction indicator
move: move the target
crosshair: cross mark
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize
38. Special effects for page entry and exit
into the page <meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
Exit page<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
These are some special effects when the page is loaded and called out. duration represents the duration of the special effect, in seconds. Transition indicates which special effect to use, the value is 1-23:
0 Reduce the rectangle 1 Expand the rectangle 2 Reduce the circle 3 Expand the circle 4 Refresh from bottom to top 5 Refresh from top to bottom 6 Refresh from left to right 7 Refresh from right to left 8 Vertical blinds 9 Horizontal blinds 10 Offset horizontal blinds 11 Offset vertical blinds 12 points Diffusion 13 left and right to middle refresh 14 middle to left and right refresh 15 middle to upper and lower 16 upper and lower to middle 17 lower right to upper left 18 upper right to lower left 19 upper left to lower right 20 lower left to upper right 21 horizontal bar 22 vertical bar 23 randomly select one of the above 22 types Type
39. Jump within the specified time
<META http-equiv=V="REFRESH" content="5;URL=http://www.soAsp.net">
40. Whether the web page is retrieved
<meta name="ROBOTS" content="attribute value">
The attribute values include the following:
The attribute value is "all": files will be retrieved and links on the page can be queried;
The attribute value is "none": the file is not retrieved, and the links on the page are not queried;
The attribute value is "index": the file will be retrieved;
The attribute value is "follow": query the link on the page;
The attribute value is "noindex": the file is not retrieved, but can be queried and linked;
The attribute value is "nofollow": the file is not retrieved, but the links on the page can be queried.