Javascript shield right-click

Source: Internet
Author: User
Tags tagname

I have not looked at it carefully. There is something useful here.

This article from hyper-threading search (cxcss) http://www.cxcss.com

Oncontextmenu = "window. event. returnvalue = false" style = "overflow-Y: hidden; overflow-X: hidden" ajs9 leftmargin = "0" topmargin = "0"

<Body oncontextmenu = "Return false"> </body>

<! -- Disable saving a webpage as: -->

<NoScript> <IFRAME src = *. html> </iframe> </NoScript>

<! -- Disable Text Selection: -->

<SCRIPT type = "text/JavaScript">

VaR omitformtags = ["input", "textarea", "select"]

Omitformtags = omitformtags. Join ("| ")

Function disableselect (e ){

If (omitformtags.indexof(e.tar get. tagname. tolowercase () =-1)

Return false

}

Function reenable (){

Return true

}

If (typeof document. onselectstart! = "Undefined ")

Document. onselectstart = new function ("Return false ")

Else {

Document. onmousedown = disableselect

Document. onmouseup = reenable

}

</SCRIPT>

<! -- Disable right-click: -->

<SCRIPT>

Function stop (){

Return false;

}

Document. oncontextmenu = stop;

</SCRIPT>

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>

11. <input type = button value = view web pageSource code

Onclick = "window. Location = 'view-Source: '+ http://www.tonightdream.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

<Script language = "JavaScript">

Function getie (e ){

VaR T = E. offsettop;

VaR L = E. offsetleft;

While (E = E. offsetparent ){

T + = E. offsettop;

L + = E. offsetleft;

<! -- Right-click to start -->

<Script language = "JavaScript">

<! --

If (window. Event)

Document. captureevents (event. mouseup );

Function nocontextmenu ()

{

Event. cancelbubble = true

Event. returnvalue = false;

Return false;

}

Function norightclick (E)

{

If (window. Event)

{

If (E. Which = 2 | E. Which = 3)

Return false;

}

Else

If (event. Button = 2 | event. Button = 3)

{

Event. cancelbubble = true

Event. returnvalue = false;

Return false;

}

}

Document. oncontextmenu = nocontextmenu; // For ie5 +

Document. onmousedown = norightclick; // for all others

// -->

</SCRIPT>

<! -- Disable Text Selection: -->

<SCRIPT type = "text/JavaScript">

VaR omitformtags = ["input", "textarea", "select"]

Omitformtags = omitformtags. Join ("| ")

Function disableselect (e ){

If (omitformtags.indexof(e.tar get. tagname. tolowercase () =-1)

Return false

}

Function reenable (){

Return true

}

If (typeof document. onselectstart! = "Undefined ")

Document. onselectstart = new function ("Return false ")

Else {

Document. onmousedown = disableselect

Document. onmouseup = reenable

}

</SCRIPT>

<Script language = "JavaScript" type = "text/JavaScript">

<! --

Function key (){

If (event. shiftkey ){

Window. Close ();}

// Disable shift

If (event. altkey ){

Window. Close ();}

// Disable alt

If (event. ctrlkey ){

Window. Close ();}

// Disable Ctrl

Return false ;}

// Document. onkeydown = key;

If (window. Event)

Document. captureevents (event. mouseup );

// Swordmaple JavaScript article.

// From www.jx165.com

Function nocontextmenu (){

Event. cancelbubble = true

Event. returnvalue = false;

Return false ;}

Function norightclick (e ){

If (window. Event ){

If (E. Which = 2 | E. Which = 3)

Return false ;}

Else

If (event. Button = 2 | event. Button = 3 ){

Event. cancelbubble = true

Event. returnvalue = false;

Return false ;}

}

// Disable right-click

Document. oncontextmenu = nocontextmenu; // For ie5 +

Document. onmousedown = norightclick; // for all others

// -->

</SCRIPT>

Related Article

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.