The following 40 javascript tips are commonly for web design.Them will be useful for the web designer.

1. Oncontextmenu = "window.event.returnValue = false" will completely shield the mouse right button
<table border oncontextmenu=return(false)><td>no</table> can be used for Table

2. <body Onselectstart="return false"> deselect to prevent copying

3. Onpaste = "return false" forbid to paste

4. Oncopy = "return false;" oncut = "return false;" to prevent copying

5. <link Rel="Shortcut Icon" href="favicon.ico"> IE address bar replace your icon before

6. <link Rel="Bookmark" href="favicon.ico"> can show your favorites icon

7. <input Style="ime-mode:disabled"> off input

8 will always be with a framework
<script language="JavaScript"> <! -
if (window == top) top.location.href = "frames.htm"; //frames.htm page as a framework

9.Prevent the frame being
if (top.location! = self.location) top.location = self.location;

10.Pages will not be saved as
<noscript> <iframe src="/blog/*.html> "; </iframe> </noscript>

11. <Input type = button value = View page source code
onclick = "window.location =" view-source: "+" "">

12.Deleting confirm
<a href="javascript:if(confirm("Really delete?"))location="boos.asp?&areyou=delete&page=1""> delete </a> _fcksavedurl = "" javascript: if (confirm ("really delete it?")) location = "boos.asp? & areyou = delete & page = 1" "> Delete </a>"

13.To obtain the absolute position of the control
<script language="Javascript">
function getIE (e) {
var t = e.offsetTop;
var l = e.offsetLeft;
while (e = e.offsetParent)
alert ("top =" + t + "/nleft =" + l);

<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
msgbox "top =" & t & chr (13) & "left =" & l, 64, "to get position of the control."
end function

14.The cursor is parked in the last textbox text
<script language="javascript">
function cc ()
var e = event.srcElement;
var r = e.createTextRange ();
r.moveStart ("character", e.value.length);
r.collapse (true); ();
<input type=text name=text1 value="123" onfocus="cc()">

15.Determine the source of previous

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=maximize onclick=hh2.Click()>
<input type=button value=closewindow onclick=hh3.Click()>
This example applies to IE

17.shield function keys Shift, Alt, Ctrl
function look () {
if (event.shiftKey)
alert ("prohibited press the Shift key!"); //can be replaced with ALT CTRL
document.onkeydown = look;

18.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 let form no concavity?
<input type=text style="border:1 solid #000000">
<Input type = text style = "border-left: none; border-right: none; border-top: none; border-bottom:1 solid # 000000 "> </textarea>

20.<div> <span> and <layer> the three difference?
<div> (division) used to define a large section of the page elements, will produce newline
<span> used to define the elements within the same line, with the only difference is <div> switch does not produce newline
<layer> is ns mark, IE does not support ,it is equivalent <div>

21.Let the pop-up window always on top:
<body onblur="this.focus();">

22.No scrollbar?
No vertical scrollbar:
<body style="overflow:scroll;overflow-y:hidden">
No horizontal scrollbar:
<body style="overflow:scroll;overflow-x:hidden">
Both remove? more simple
<body scroll="no">

23.How to remove the image link clicked, the picture around the dotted line?
<a href="#" onFocus="this.blur()"> <img src="/blog/logo.jpg" border=0> </a>

24.E-mail processing submission form
<form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain">
<input type=submit>

25.Open child window to refresh parent window code
window.opener.location.reload ()

26.How to set the opening page size
<body onload="top.resizeTo(300,200);">
Open the page position <body onload="top.moveBy(300,200);">

27.How to add the page background image is not full of shops, pulling a page background image does not move
{Background-image: url (/blog /logo.gif); background-repeat: no-repeat;
background-position: center; background-attachment: fixed}

28.Check whether a string is composed entirely of digital
<script language="Javascript"> <! -
function checkNum (str) {return str.match (//D /) == null}
alert (checkNum ("1232142141"))
alert (checkNum ("123214214a1"))

29.To obtain the size of a window
document.body.clientWidth; document.body.clientHeight

30.How to determine whether the character
if (/[^/x00-/xff] /g.test (s)) alert ("with Chinese characters");
else alert ("all characters");

31.The TEXTAREA adaptive number of text lines
<textarea rows=1 name=s1 cols=27 onpropertychange="">

32.Date minus the number of days equal to the second date
<script language=Javascript>
function cc (dd, dadd)
//Add error handling
var a = new Date (dd)
a = a.valueOf ()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date (a)
alert (a.getFullYear () + "years" + (a.getMonth () + 1) + "months" + a.getDate () + "day")
cc ("12/23/2002", 2)

33.Which Radio is selected
<HTML> <script Language="vbscript">
function checkme ()
for each ob in radio1
if ob.checked then window.alert ob.value
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()">

34.The script never wrong
<! - Hide
function killErrors () {
return true;
window.onerror = killErrors;

35.ENTER key allows the cursor move to the next input box
<input onkeydown="if(event.keyCode==13)event.keyCode=9">

36.Detected link speed of a site:
Paste this code into <body> area:
<script language=Javascript>
tim = 1
setInterval ("tim + +", 100)
b = 1
var autourl = new Array ()
autourl [1] = ""
autourl [2] = ""
autourl [3] = ""
autourl [4] = ""
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="/blog/testing...>" = "<input type = text
name = url "+i+" size =40> = "<input type = button value = GO

onclick = (this.form.url "+i+". value)><br> ")
document.write ("<input type=submit value=refresh></form>")
function auto (url)
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 the cursor
auto: standard cursor
default: standard arrow
hand: the hand cursor
wait: wait for the cursor
text: I-shaped cursor
vertical-text: horizontal I-shaped cursor
no-drop:  the cursor can not be drag
not-allowed: invalid cursor
help: help cursor
all-scroll: Triangle direction indicator
move: move cursor
crosshair: crosshair cursor

38.Pages to enter and exit effects
Into the page <meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
Leave page <meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
This is the page is loaded and transferred out to some of the effects. that the duration of effects duration, in seconds. what kind of transition that the use of special effects, a value of 1-23:
0 rectangle narrow
1 rectangular expansion
2 round narrow
3 round expansion
4 refresh from bottom to top
5 refresh from top to bottom
6 refresh from left to right
7 refresh right to left
8 vertical blinds
9 horizontal blinds
10 dislocation horizontal blinds
11 dislocation vertical blinds
12 point spread
13 refresh  from sides to middle
14 refresh from middle to sides
15 refresh from middle to up and down
16 refresh from up and down to middle
17 refresh from right bottom to left top
18 refresh from right top to left bottom
19 refresh from left top to right bottom
20 refresh from left bottom to right top
21 horizontal bar
22 vertical bar
23 randomly select one style

39.Jumps within the specified time
<META Http-equiv=V="REFRESH" content="5;URL=">

40.If pages are retrieved
<meta name="ROBOTS" content="parameter">
Which property values ??are the following:
Parameter value "all": the file will be retrieved, and the page link can be queried;
Parameter is "none": file not be retrieved, and do not check the links on the page;
Parameter value "index": the file will be retrieved;
Parameter value "follow": Query link on the page;
Parameter value "noindex": file is not be retrieved, but the link can be queried;
Parameter value "nofollow": file not be retrieved, but can check the links on the page.

This address is