Webpage code is the result of the work of the producer. Some people can use browsers or other means to steal the original webpage code. Therefore, we need some preventive measures.
Bytes ------------------------------------------------------------------------------------------------------
1. oncontextmenu = "window. event. returnvalue = false" // The right mouse button is permanently blocked.
<Table border oncontextmenu = return (false)> <TD> NO </table> //
Bytes ------------------------------------------------------------------------------------------------------
2. <body onselectstart = "Return false"> // cancel the selection to prevent replication.
Bytes ------------------------------------------------------------------------------------------------------
3. onpaste = "Return false" // do not paste
Bytes ------------------------------------------------------------------------------------------------------
4. oncopy = "Return false;" oncut = "Return false;" // prevents Replication
Bytes ------------------------------------------------------------------------------------------------------
5. // prevent Frame
<Script language = JavaScript> <! --
If (top. location! = Self. Location) top. Location = self. location;
// --> </SCRIPT>
Bytes ------------------------------------------------------------------------------------------------------
6. <NoScript> <IFRAME src = *. html> </iframe> </NoScript> // The webpage cannot be saved
Bytes ------------------------------------------------------------------------------------------------------
7. // changing the connection is the display content of the status bar
<A href = "http://v.2best.cc" onmouseover = "window. Status = 'Enter the connection status bar display content'; return true">
Bytes ------------------------------------------------------------------------------------------------------
8. // disable the download of the target object on the webpage)
The following code disables the download of the target object on the webpage:
<A href = "javascript: void (0)" onmousedown = "alert ('Sorry! Images cannot be downloaded! ') ">
</A>
Bytes ------------------------------------------------------------------------------------------------------
9. // The page cannot be refreshed completely
It is best to use it in pop-out windows without a toolbar.
<Body onkeydown = "keydown ()" onbeforeunload = "location = location"
Oncontextmenu = "event. returnvalue = false">
<Script language = "JavaScript"> <! --
Function keydown (){
If (window. event. altkey )&&
(Window. event. keycode = 37) |
(Window. event. keycode = 39) {alert ("visit my homepage ");
Event. returnvalue = false;
}
If (event. keycode = 8) | (event. keycode = 116) {// block the F5 refresh key
Event. keycode = 0;
Event. returnvalue = false;
}
If (event. ctrlkey) & (event. keycode = 78) {// block Ctrl + n
Event. returnvalue = false;
}
If (event. shiftkey) & (event. keycode = 121) {// block SHIFT + F10
Event. returnvalue = false;
}
}
</SCRIPT>
</Body>
Bytes ------------------------------------------------------------------------------------------------------
10. // how to completely prohibit viewing the webpage source code
From: http://www.ccw.com.cn/htm/app/aprog/01_12_11_3.asp
Web page makers often encounter situations where specially crafted Javascript effects are copied by others, but they are helpless. Is there a way to solve this problem? Server-side programming technologies such as ASP and JSP can be used to protect the source code of web pages. However, the free personal homepage space provided by domestic websites generally does not support server-side programming, therefore, to prohibit visitors from viewing the source code of the web page, they can only work on client programming.
View Source Code
To prohibit visitors from viewing the source code of a Web page, we first need to know how to view the source code (taking IE 5.0 as an example ). One is right-click menu, and the other is Window Menu view, that is, select "View" * "Source File. To completely prohibit visitors from viewing the source code of a webpage, you must block these two ways to view the source code.
Blocked right-click menu viewing
Currently, many web pages use the following code to shield the right-click menu:
<Script language = JavaScript>
Function click (){
If (event. Button = 2) {alert
('Copyright (c) 2001 XXX studio ');
}}
Document. onmousedown = click;
</SCRIPT>
In fact, "button" has eight attribute values (0 ~ 7), "button = 2" only means to press the right mouse button, so the above Code can only limit the right mouse click, as for the other five methods, if you press both the left and right keys, the middle keys, the left and the middle keys, the right and the middle keys, and all the keys at the same time, you cannot restrict them. The shortcut menu is displayed after you press "OK" in the displayed dialog box (as shown in 3. In this case, you only need to change "event. Button = 2" to "event. Button! = 1 ", no matter what type of mouse click is used, no right-click menu appears.
However, even after the preceding modification, the appearance of the right-click menu cannot be completely disabled. You only need to right-click the page. After the page prompts "copyright information", the right-click will not be released (that is, the press will continue ), move the mouse pointer to the "OK" button in the copyright information Prompt window, press the left button, and then release the left mouse button. The Prompt window disappears. Then, right-click the page and right-click the page to view the source file.
Is there a way to completely disable the appearance of the shortcut menu? In fact, you only need to modify the above Code as follows.
<Script language = JavaScript>
Function click (){
Alert ('copyright (c) 2001 XXX studio ');
Window. event. returnvalue = false;
}
Document. oncontextmenu = click;
</SCRIPT>
In this way, the shortcut menu will no longer appear no matter how you click the mouse. However, if you directly type "javascript: Alert (document. oncontextmenu ='') "in the address bar of your browser, you can remove the right-click menu. How can we prevent such visitors? In fact, you can hide the address bar. For more information, see "display the blocked Window menu bar ".
How to view the shield Window Menu Bar
Anyone who has made a web page knows that you can control the attributes of the newly opened window, including the control menu bar, the scroll bar, and whether the address bar is visible. If you close the parent window and hide the menu bar and address bar of the newly opened window, can you shield the display mode of the window menu bar? The implementation code is as follows:
<Head>
<Object ID = closes type = "application/X-oleobject"
Classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "command" value = "close">
</Object>
</Head>
<Body>
<Script language = JavaScript>
Closes. Click ()
Window. Open ("xxx.htm", "", "menubar = No, location = No,
Scrollbars = Yes, resizable = yes ")
</SCRIPT>
</Body>
In this case, the website's first page is created in the form of index.htm, And the homepage is designed as a transition page. After that, the real main page of the website will be created in the default.htm form (for the specific implementation process, see the source code attached to this Article ). In this way, visitors can no longer view the source code of the webpage. This not only protects your copyright, but also guarantees further development. In this way, you can combine Cookie technology to truly restrict users from browsing the Web page, so as to avoid illegal access to the home page information.
Appendix: source code list
Index.htm
<Head>
<Object ID = closes type = "application/X-oleobject" classid = "CLSID:
Adb880a6-d8ff-11cf-9377-00aa003b7a11>
<Param name = "command" value = "close">
</Object>
</Head>
<Body>
<Script language = JavaScript>
Closes. Click ()
Window. Open ("defalut.htm", "", "menubar = No, location = No,
Scrollbars = Yes, resizable = yes ")
</SCRIPT>
</Body>
Default.htm
<HTML>
<Head>
<Script language = JavaScript>
Function click (){
Alert ('copyright (c) 2001 XXX studio ');
Window. event. returnvalue = false;
}
Document. oncontextmenu = click;
</SCRIPT>
</Head>
<Body>
......
</Body>
</Html>
Note: The content involved in this article passes the test under Windows 98/IE 5.0.