10 must-have tips for javascript

10 must-have tips for javascript

1. Completely shield the right mouse button
oncontextmenu="window.event.returnValue=false"

2. Cancel selection, prevent copying
<body onselectstart="return false">
oncopy="return false;" oncut="return false;"

3. Pasting is prohibited
onpaste="return false"

4. Replace the IE address bar with its own icon
<link rel="Shortcut Icon" href="favicon.ico">

5. Show your own icon in the favorites
<link rel="Bookmark" href="favicon.ico">

6. Turn off the input method
<input style="ime-mode:disabled">

7. Get the size of a window

document.body.clientWidth; document.body.clientHeight

8. Special effects of page entry and exit:

Enter the page <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 when the page is loaded and recalled. Duration represents the duration of the special effect, in seconds. Transition indicates which special effect is used, the value is 1-23:
0 Rectangular reduction
1 Rectangular expansion
2 Circle reduction
3 Circle expansion
4 Bottom to top refresh
5 Top to bottom refresh
6 Left to right refresh
7 Right to left refresh
8 Vertical Blinds
9 Horizontal Blinds
10 Displacement Horizontal Blinds
11 Displacement Vertical Blinds
12 Point Spread
13 Left-Right to Center Refresh
14 Center to Left-Right Refresh
15 Center to Up and Down
16 Up and Down to Center
17
Bottom Right to Top Left 18 Top Right to Bottom Left
19 Top Left to Bottom Right
20 Bottom Left to Top right
21 horizontal bar
22 vertical bar

9. Shield function keys Shift, Alt, Ctrl
<script> function look(){ if(event.shiftKey) alert("禁止按Shift键!"); //可以换成ALTCTRL } document.onkeydown=look; </script>
10. 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">
<META HTTP-EQUIV="expires" CONTENT="0">
11. Set the size and position of the page to open
<body onload="top.resizeTo(300,200);">
<body onload="top.moveBy(300,200);"

Guess you like

Origin blog.csdn.net/qq_43237014/article/details/114399593