Common HTML special effect code
1. Ignore right-click
<Body oncontextmenu = "return false">
Or
<Body style = "overflow-y: hidden">
2. Add background music
IE: <bgsound src = "*. mid" loop = infinite>
NS: <embed src = "*. mid" autostart = true hidden = true loop = true>
</Embed>
*. Mid: the midi format file of your background music
3. Simple window. open method
<A href = "#"
Onclick = "javascript: window. open (file path/file name, newwindow,
Toolbar = no, scrollbars = yes, resizable = no, top = 0, left = 0,
Width = 400, height = 300); "> text or image </a>
Parameter description:
<Script language = "javascript"> The js SCRIPT starts;
Window. open command to pop up a new window;
File name in the file path/file name pop-up window;
The name (not the file name) of the newwindow pop-up window. It is optional and can be replaced by null;
Width = 400 window width;
Height = 300 window height;
Top = the pixel value between the 0 window and the top of the screen;
Left = 0 the pixel value between the window and the left of the screen;
Toolbar = no indicates whether to display the toolbar. yes indicates display;
Menubar and scrollbars indicate the menu bar and scroll bar.
Resizable = no: whether to change the window size. yes: yes;
Location = no indicates whether the address bar is displayed. yes indicates yes;
Status = no whether to display the information in the status bar (usually the file has been opened), yes is allowed;
</SCRIPT> end of js SCRIPT
4. Simple page encryption
<Script LANGUAGE = "javascript">
<! --
Function loopy (){
Var sWord = "";
While (sWord! = "Login") {sWord = prompt ("enter your login password ");}
Alert ("login successful! ");
}
Loopy ()
// -->
</Script>
5. The background image does not move when pulling the page
<Style>
Body {background-image: url(logo.gif );
Background-repeat: no-repeat; background-position: center}
</Style>
6. An error occurred while saving the page by the browser.
<NOSCRIPT> <iframe src = "*. html"> </iframe> </NOSCRIPT>
7. Random Image replacement
<Script>
Document. write (Pai.gif "height =" 40 "width =" 50 ">
</Script>
The image file is named 0.gif 1.gif 2.gif 3.gif 4.gif.
8. Window timed close
Add the following code to the webpage File area:
<Script language = "javascript">
Function closeit () {setTimeout ("self. close ()", 10000) // millisecond}
</Script>
Then add the following content to the <body> label: <body onload = "closeit ()">
9. Web page automatically closed
<Html>
<Head>
<Object id = closes type = "application/x-oleobject"
Classid = "clsid: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "Command" value = "Close">
</Object>
</Head>
<Body onload = "window. setTimeout (closes. Click (), 10000)">
This window will be automatically closed 10 seconds later and will not be prompted.
</Body>
</Html>
10. Automatic webpage refresh
Record in head
<META HTTP-EQUIV = "Refresh" content = "20">
The refresh is automatically refreshed 20 seconds later. You can change it to any value.
11. Automatic webpage conversion
<META HTTP-EQUIV = "Refresh" CONTENT = "time (SEC); URL = address">
12. Keep the layer at the beginning without being overwritten by Iframe and Object.
Insert the Iframe or Object in the Layer to set the z-Index value.
<Div z-Index: 2> <object xxx> </object> # front
<Div z-Index: 1> <object xxx> </object> #
<Div id = "Layer2" style = "position: absolute; top: 40; width: 400px;
Height: 95px; z-index: 2 "> height = 100% width = 100%>
<Iframe width = 0 height = 0> </iframe>
</Div>
<Div id = "Layer1" style = "position: absolute; top: 50; width: 200px;
Height: 115px; z-index: 1 ">
<Iframe height = 100% width = 100%> </iframe>
</Div>
13. Back to previous page
<A href = javascript: history. back (1)> "back to previous page" </a>
14. Close Window
<A href = javascript: self. close ()> close Window </a>
15. Transparent Background of iframe
<Iframe id = "iFrame1" SRC = "iframe.htm"
AllowTransparency = "true"
Style = "background-color: green"> </IFRAME>
16. oncontextmenu = "window. event. returnValue = false" will completely block the right mouse button
<Table border oncontextmenu = return (false)> <td> no </table>
17. <body onselectstart = "return false"> cancel selection to prevent replication
18. onpaste = "return false" do not paste
19. oncopy = "return false;" oncut = "return false;" prevent replication
20. <link rel = "Shortcut Icon" href = "favicon. ico"> replace it with your own Icon in front of the IE address bar
21. <link rel = "Bookmark" href = "favicon. ico"> You can display your icons in favorites.
22. <input style = "ime-mode: disabled"> disable the input method.
23. Always carry the framework
<Script language = "JavaScript"> <! --
If (window = top) top. location. href = "frames.htm"; // frames.htm is the frame webpage.
// --> </Script>
24. Prevent frame
<Script language = JAVASCRIPT> <! --
If (top. location! = Self. location) top. location = self. location;
// --> </SCRIPT>
25. Web pages cannot be saved
<Noscript> <iframe src = *. html> </iframe> </noscript>
26. View the webpage source code
<Input type = button value = view web page source code onclick = "window. location =" view-source: "+" http://www.pconline.com.cn "">
27. Confirm deletion
<A href = "javascript: if (confirm (" Are you sure you want to delete it? ") Location =" boos. asp? & Areyou = delete & page = 1 "> delete </a>
28. 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>