The most commonly used JS code in Web pages (JS no right-click, no copying)

Source: Internet
Author: User

<body oncontextmenu= "return false" ></body>

<!– Disable Right-click:–>
<script>
function Stop () {
return false;
}
Document.oncontextmenu=stop;
</script>

<body onselectstart= "return false" > deselect, prevent copying

Oncopy= "return false;" oncut= "return false;" Prevent replication

Four: Disable viewing of source files

<script>
function Clear () {
Source=document.body.firstchild.data;
Document.open ();
Document.close ();
Document.title= "Cannot see the source code";
Document.body.innerhtml=source;
}</script>

Five, the picture download limit
<script language= "JavaScript" >
function Click () {
if (window.event.srcelement.tagname== "IMG")
{
Alert (' Picture directly right ');
Window.event.returnvalue=false;
}
}
Document.oncontextmenu=click;
</script>

<meta http-equiv= "Imagetoolbar" content= "no" >  
Add galleryimg property when inserting a picture

disable right-saving
Place the following code between <script language=java script>
Function Click () {
Alert (' Sorry, you can't save this picture, thank you for your understanding and support! ')}
Function Click1 () {
if (event.button==2) {alert (' Sorry, you cannot save this picture, thank you for your understanding and support! ')}}
Function CtrlKeyDown () {
if (event.ctrlkey) {alert (' improper copy will damage your system! ')}}
Document.onkeydown=ctrlkeydown;
Document.onselectstart=click;
Document.onmousedown=click1;
</script>

Way two:
Add the following JS code to the page: Principle: Shield Right button
<script>
function Document.onmousedown ()
{
if (event.button==2| | EVENT.BUTTON==3)
{
Alert ("Right Jian is forbidden")
return False
}

}
</script>

Web page anti-copy code prevents viewing Web page source file code
You can insert a Web page.
<body leftmargin= "2″topmargin=" 0″marginwidth= "0″marginheight=" 0″oncontextmenu= "return

False "ondragstart=" return false "Onselectstart =" return false "

Onselect= "Document.selection.empty ()" oncopy= "Document.selection.empty ()"

Onbeforecopy= "return false" onmouseup= "Document.selection.empty ()" >

<noscript><iframe src= "/blog/*>";</iframe></noscript>

1. oncontextmenu= "Window.event.returnvalue=false"//will completely shield the right mouse button
<table border Oncontextmenu=return (false) ><td>no</table>//Available for table
——————————————————————————————–

———-

2. <body onselectstart= "return false" >//deselect, prevent copying
——————————————————————————————–

———-

3. onpaste= "return false"//No paste
——————————————————————————————–

———-

4. oncopy= "return false;" oncut= "return false;"//Prevent replication

——————————————————————————————–

———-

5.//Prevent people from being frame
<script language=javascript><!–
if (top.location! = self.location) top.location=self.location;
–></script>

——————————————————————————————–

———-

6. <noscript><iframe src= "/blog/*.html>";</iframe></noscript>//Web page will not be saved as

——————————————————————————————–

———-

7.//Change the connection is the status bar display content

〈a href= "http://v.2best.cc" Onmo ...; window.status= ' Input connection status bar display content '; return True ' >

——————————————————————————————–

———-

8.//Prohibit the target object from being downloaded in the webpage (slice)

The following code will help you prevent the target object from being downloaded in the Web page:

<a href= "javascript:void (0)" onmousedown= "alert (' Sorry! Pictures cannot be downloaded! ') ' >

</a>

——————————————————————————————–

———-

9.//page Disable refresh completely
It's best to use pop-out windows, no toolbars.
<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 ("Please visit my home page");
Event.returnvalue=false;
}
if ((event.keycode==8) | | | (event.keycode==116)) {//Mask F5 Refresh key
event.keycode=0;
Event.returnvalue=false;
}
if ((Event.ctrlkey) && (event.keycode==78)) {//shielded CTRL + N
Event.returnvalue=false;
}
if ((Event.shiftkey) && (event.keycode==121)) {//shielded SHIFT+F10
Event.returnvalue=false;
}
}
</script>
</body


The most commonly used JS code in Web pages (JS no right-click, no copying)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.