1. oncontextmenu = "window. event. returnvalue = false" will completely block the right mouse button
<Table border oncontextmenu = return (false)> <TD> NO </table>
2. <body onselectstart = "Return false"> cancel selection to prevent Replication
3. onpaste = "Return false" Do not paste
4. oncopy = "Return false;" oncut = "Return false;" Prevent Replication
5. <LINK rel = "shortcut icon" href = "favicon. ICO"> replace it with your own icon in front of the IE Address Bar
6. <LINK rel = "bookmark" href = "favicon. ICO"> your Icons can be displayed in favorites.
7. <input style = "ime-mode: Disabled"> disable the input method.
8. Always carry the framework
<Script language = "JavaScript"> <! --
If (window = Top) top. Location. href = "frames.htm"; // frames.htm is the frame webpage.
// --> </SCRIPT>
9. Prevent Frame
<Script language = JavaScript> <! --
If (top. location! = Self. Location) top. Location = self. location;
// --> </SCRIPT>
10. The webpage cannot be saved
<NoScript> <*** src = "/*. html>"; </***> </NoScript>
11. <input type = button value = "/view webpageSource code
Onclick = "window. Location =" view-source: "+" http://www.cnblogs.com "">
12. Confirm deletion
<A href = "" javascript: If (confirm ("are you sure you want to delete it? ") Location =" boos. asp? & Areyou = Delete & page = 1 "> Delete </a>
13. obtain the absolute position of the Control
// JavaScript
// VBScript
14. The cursor stops 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, 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 = "/blog/maximized onclick = hh2.click ()>
<Input type = button value = Disable onclick = hh3.click ()>
This example applies to IE
17. Block function keys shift, ALT, CTRL
<SCRIPT>
Function look (){
If (event. shiftkey)
Alert ("do not press shift! "); // You can change it to alt CTRL
}
Document. onkeydown = look;
</SCRIPT>
18. The webpage 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 feel free of attention?
<Input type = text "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 are the differences between <div> <span> & <layer>?
<Div> (Division) is used to define the page elements of a large segment, and a line is generated.
<Span> is used to define elements in the same row. The only difference between <div> and <div> is that no transpose is generated.
<Layer> is the NS tag, which is not supported by IE, which is equivalent to <div>
21. Make the pop-up window always on the top:
<Body onblur = "This. Focus ();">
22. Do not use a scroll bar?
Make the vertical bar not:
<Body style = "overflow: Scroll; overflow-Y: hidden">
</Body>
Make the horizontal bar unavailable:
<Body style = "overflow: Scroll; overflow-X: hidden">
</Body>
Remove both of them? Simpler
<Body scroll = "no">
</Body>
23. How do I remove the dotted line around the image after clicking the image link?
<A href = "#" onfocus = "This. Blur ()"> </a>
24. email processing submission form
<Form name = "form1" method = "Post" Action = mailto: ***** @ ***. com
Enctype = "text/plain">
<Input type = submit>
</Form>
25. RefreshCodeHow to write?
Window. opener. Location. Reload ()
26. How to set the page size
<Body onload = "Top. resizeTo (300,200);">
<Body onload = "Top. moveBy (300,200);">
27. How to add a background image that is not full? The background image does not move 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 digits.
<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 ("containing Chinese characters ");
Else alert ("All characters ");
31. Number of lines of textarea adaptive text
<Textarea rows = 1 name = S1 Cols = 27 onpropertychange
= "This. style. posheight = This. scrollheight">
</Textarea>
32. The date minus the number of days equals 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 * 24x60*60*1000
A = new date ()
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 = "/blog/barcode"> Barcode
<Input type = "button" value = "check" onclick = "checkme ()">
</Body>
34. Script never fails
<Script language = "JavaScript">
<! -- Hide
Function killerrors (){
Return true;
}
Window. onerror = killerrors;
// -->
</SCRIPT>
35. Press enter to 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] = 1000) {This. resized = true; this. style. width = 1000;} "align = absmiddle border = 0> http://www.njcatv.net /"
Autourl [2] = "javacool.3322.net"
Autourl [3] = 1000) {This. resized = true; this. style. width = 1000;} "align = absmiddle border = 0> http://www.sina.com.cn /"
Autourl [4] = "www.cnblogs.com"
Autourl [5] = 1000) {This. resized = true; this. style. width = 1000;} "align = absmiddle border = 0> http://www.cctv.com /"
Function Butt (){
*** ("<Form name = autof> ")
For (VAR I = 1; I <autourl. length; I ++)
*** ("<Input type = text name = TXT" + I + "size = 10 value ="/testing...> = "<Input type = text
Name = URL "+ I +" size = 40 >=" <input type = button value = "/blog/go
Onclick = Window. Open (this. Form. url "+ I +". Value)> <br> ")
*** ("<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 = "/blog/Time" + TIM/10 + "seconds "}
B ++
}
Function run () {for (VAR I = 1; I <autourl. length; I ++) *** ("Onerror = auto ("http: //" + autourl + "")> ")}
Run () </SCRIPT>
37. Various styles of cursor
Auto: Standard cursor
Default: Standard arrow
Hand: Hand-shaped cursor
Wait: waiting for the cursor
Text: I-shaped cursor
Vertical-text: horizontal I-shaped cursor
No-drop: Do not drag the cursor
Not-allowed: Invalid cursor
Help :? Help cursor
All-scroll: triangle direction indicator
Move: Move mark
Crosshair: Cross logo
E-resize
N-resize
NW-resize
W-resize
S-resize
Se-resize
Sw-resize
38. Special Effects for entering and exiting the page
Go to the <meta http-equiv = "Page-Enter" content = "revealtrans (duration = x, transition = y)">
Launch page <meta http-equiv = "Page-Exit" content = "revealtrans (duration = x, transition = y)">
This is some special effects of page loading and calling. Duration indicates the duration of the special effect, in seconds. Transition indicates which special effect is used. The value ranges from 1 to 23:
0 rectangular narrowing
1. rectangular enlargement
2 rounded down
3. Circular Expansion
4. Refresh from bottom to top
Refresh from top to bottom
6-left-right refresh
7. right-to-left refresh
8 vertical blinds
9 horizontal blinds
10 misplaced horizontal blinds
11 misplaced vertical blinds
Spread
Refresh from around 13 to the center
14. Refresh from center to left
15.
16 up to the middle
17 bottom right to top left
18 top right to bottom left
19 upper left to lower right
20 bottom left to top right
21 horizontal bars
22 vertical bars
23 or more 22 types of random selection
39. Jump within the specified time
<Meta http-equiv = V = "refresh" content = "5; url = http://www.51js.com">
40. Whether the webpage is retrieved
<Meta name = "Robots" content = "attribute value">
The attribute values include the following:
Attribute Value: "All": the file will be retrieved and the link on the page can be queried;
Attribute Value: "NONE": the file is not retrieved and the link on the page is not queried;
The property value is "Index": the file will be retrieved;
The property value is "follow": the link on the query page;
Attribute Value: "noindex": the file is not retrieved, but can be queried;
The property value is "nofollow": the file is not retrieved, but the link on the page can be queried.
41. Email address segmentation
Add the following code to the <body> area:
<A href = "mailto: homezzm@126.com"> homezzm@126.com </a>
42. Flow Border effect table
Add the following code to the <body> area:
<SCRIPT>
L = array (6, 7, 8, 9, 'A', 'B', 'B', 'C', 'D', 'E', 'F ')
Nx = 5; ny = 35
T = "<Table border = 0 cellspacing = 0 cellpadding = 0 Height =" + (nx + 2) * 16) + "> <tr>"
For (x = NX; x <NX + ny; X ++)
T + = "<TD width = 16 id = a_mo" + x + "> </TD>"
T + = "</tr> <TD width = 10 Id = a_mo" + (Nx-1) + "> </TD> <TD colspan =" + (Ny-2) + "rowspan =" + (nx) + "> </TD> <TD width = 16 id = a_mo" + (nx + ny) + "> </TD> </tr>"
For (x = 2; x <= NX; X ++)
T + = "<tr> <TD width = 16 id = a_mo" + (NX-x) + "> </TD> <TD width = 16 id = a_mo" + (NY + NX + x-1) + "> </TD> </tr>"
T + = "<tr>"
For (x = NY; x> 0; X --)
T + = "<TD width = 16 id = a_mo" + (x + NX * 2 + Ny-1) + "> </TD>"
* ** (T + "</tr> </table> ")
VaR n = NX * 2 + ny * 2
Function F1 (y ){
For (I = 0; I <n; I ++ ){
C = (I + Y) % 20; If (C> 10) C = 20-c
Document. All ["a_mo" + (I)]. bgcolor = "#0000" + L [c] + L [c] + "'"}
Y ++
SetTimeout ('f1 ('+ Y +') ', '1 ')}
F1 (1)
</SCRIPT>
43. Javascript homepage pop-up window skills
Window pop-up in the middle
<SCRIPT>
Window. open ("http://www.cctv.com", "", "width = 400, Height = 240, Top =" + (screen. availHeight-240)/2 + ", Left =" + (screen. availWidth-400)/2 );
</SCRIPT>
================
<HTML>
<Head>
<Script language = "livescript">
Function winopen (){
MSG = open ("", "displaywindow", "toolbar = No, directories = No, menubar = No ");
MSG. *** ("MSG. *** ("<center> }
</SCRIPT>
</Head>
<Body>
<Form>
<Input type = "button" name = "button1" value = "Push me" onclick = "winopen ()">
</Form>
</Body>
</Html>
====================
1. In the following code, you only need to click to open a window to link to CCID. When you want to close the window, you just need to click it to close the window you just opened.
The Code is as follows:
<Script language = "JavaScript">
<! --
Function openclk (){
Another = open ('2017) {This. resized = true; this. style. width = 1000;} "align = absmiddle border = 0> http://www.ccidnet.com % 20/, 'newwindow ');
}
Function closeclk (){
Another. Close ();
}
// -->
</SCRIPT>
<Form>
<Input type = "button" name = "open" value = "/open a window" onclick = "openclk ()">
<Br>
<Input type = "button" name = "close" value = "/blog/close this window" onclick = "closeclk ()">
</Form>
2. The above code is too static. Why not be dynamic? It would be nice if you could give the page a landing effect!
The Code is as follows:
<SCRIPT>
Function drop (n ){
If (self. moveBy ){
Self. moveBy (0,-900 );
For (I = N; I> 0; I --){
Self. moveBy (0, 3 );
}
For (j = 8; j> 0; j --){
Self. moveBy (0, J );
Self. moveBy (J, 0 );
Self. moveBy (0,-j );
Self. moveBy (-J, 0 );
}
}
}
</SCRIPT>
<Body onload = "drop (300)">
3. Hate that many websites always open in the default window. How nice is it if you can control the opened window as you like.
The Code is as follows:
<Script language = "JavaScript">
<! -- Begin
Function popuppage (L, t, W, h ){
VaR windowprops = "location = No, scrollbars = No, menubars = No, toolbars = No, resizable = yes" +
", Left =" + L + ", Top =" + T + ", width =" + W + ", Height =" + h;
VaR url = "www.cnblogs.com ";
Popup = Window. Open (URL, "menupopup", windowprops );
}
// End -->
</SCRIPT>
<Table>
<Tr>
<TD>
<Form name = popupform>
<PRE>
Parameters on the page <br>
Left distance: <input type = text name = left size = 2 maxlength = 4> pixels
Distance from the right: <input type = text name = Top size = 2 maxlength = 4> pixels
Window width: <input type = text name = width size = 2 maxlength = 4> pixels
Window height: <input type = text name = height size = 2 maxlength = 4> pixels
</PRE>
<Center>
<Input type = button value = "open this window! "Onclick =" popuppage (this. Form. Left. value, this. Form. Top. value, this. Form. Width. value,
This. Form. Height. Value) ">
</Center>
</Form>
</TD>
</Tr>
</Table> you only need to enter a value in the corresponding dialog box. The window on the page to be opened is well controlled.
44. Page opening and moving
Add the following code to the <body> area:
<Script language = "JavaScript">
<! -- Begin
For (t = 2; t> 0; t --){
For (x = 20; x> 0; X --){
For (y = 10; y> 0; y --){
Parent. moveBy (0,-x );
}
}
For (x = 20; x> 0; X --){
For (y = 10; y> 0; y --){
Parent. moveBy (0, x );
}
}
For (x = 20; x> 0; X --){
For (y = 10; y> 0; y --){
Parent. moveBy (x, 0 );
}
}
For (x = 20; x> 0; X --){
For (y = 10; y> 0; y --){
Parent. moveBy (-X, 0 );
}
}
}
// -->
// End -->
</SCRIPT>
45. display the date and time of the personal client machine
<Script language = "livescript">
<! -- Hiding
Today = new date ()
* ** ("Current time:", today. gethours (), ":", today. getminutes ())
* ** ("<Br> today's date:", today. getmonth () + 1, "/", today. getdate (), "/", today. getyear ());
// End hiding contents -->
</SCRIPT>
46. The last modification date is automatically generated for you each time:
<HTML>
<Body>
This is a simple HTML-page.
<Br>
Last changes:
<Script language = "livescript">
<! -- Hide script from old browsers
*** (Document. lastmodified)
// End hiding contents -->
</SCRIPT>
</Body>
</Html>
47. The email address cannot be empty:
<HTML>
<Head>
<Script language = "JavaScript">
<! -- Hide
Function test1 (form ){
If (Form. text1.value = "")
Alert ("You didn't write anything about Hedong XI. Please try again! ")
Else {
Alert ("hi" + form. text1.value + "! You have entered the result! ");
}
}
Function Test2 (form ){
If (Form. text2.value = "" |
Form. text2.value. indexof ('@', 0) =-1)
Alert ("This is not the correct email address! Please try again! ");
Else alert ("You have entered! ");
}
// -->
</SCRIPT>
</Head>
<Body>
<Form name = "first">
Enter your name: <br>
<Input type = "text" name = "text1">
<Input type = "button" name = "button1" value = "input test" onclick = "test1 (this. Form)">
<P>
Enter your e-mail address: <br>
<Input type = "text" name = "text2">
<Input type = "button" name = "button2" value = "input test" onclick = "Test2 (this. Form)">
</Body>
48. marquee
<HTML>
<Head>
<Script language = "JavaScript">
<! -- Hide
VaR scrtxt = "what's wrong! Cool! You can also try. "+" Here goes your message the visitors to your
Page will "+" look at for hours in pure fascination ...";
VaR lentxt = scrtxt. length;
VaR width = 100;
VaR Pos = 1-width;
Function scroll (){
Pos ++;
VaR scroller = "";
If (Pos = lentxt ){
Pos = 1-width;
}
If (Pos <0 ){
For (VAR I = 1; I <= math. Abs (POS); I ++ ){
Scroroller = scroroller + "";}
Scroller = scroller + scrtxt. substring (0, width-I + 1 );
}
Else {
Scroller = scroller + scrtxt. substring (Pos, width + POS );
}
Window. Status = scroller;
SetTimeout ("scroll ()", 150 );
}
// -->
</SCRIPT>
</Head>
<Body onload = "scroll (); Return true;">
Your webpage is displayed here!
</Body>
</Html>
49. Use buttons on the webpage to control the display of the front page, back page, and home page.
<HTML>
<Body>
<Form name = "buttonbar">
<Input type = "button" value = "back" onclick = "history. Back ()">
<Input type = "button" value = "js-home" onclick = "locationpolic'script.html '">
<Input type = "button" value = "Next" onclick = "history. Forward ()">
</Form>
</Body>
</Html>
50. view the source code of a website
Add the following code to the <body> area:
<SCRIPT>
Function add ()
{
VaR RESS = Document. Forms [0]. luxiaoqing. Value
Window. Location = "view-source:" + RESS;
}
</SCRIPT>
Enter the URL to view the source code:
<Form> <input type = "text" name = "luxiaoqing" size = 40 value = "http: //"> </form>
<Form> <br>
<Input type = "button" value = "view source code" onclick = add ()>
</Form>
51. Close the page 15 seconds later
Onload = "setTimeout ('window. Close ()", 15000 )"