Disable Right Click and Copy in Webpage

By | October 3, 2012

Disabling right click and selecting the text will keep our website content not to be duplicated. You may ask, why we have to restrict user not to duplicate our content? when our content is duplicated and published in some other website, they will get credit and this may rise SEO problem.

 

Disable right click

oncontextmenu – Event handler property, which will be triggered when user makes a right click in the webpage. When this event is called in webpage, false will be returned.

[code type=html]
<html>
<body oncontextmenu=”return false;”>
Just make a right click in this page .
</body>
</html>
[/code]

Disable selecting text

onselectstart – Event handler property, which will be triggered when user selects the text in webpage. When text in webpage is selected, onselectstart will return false.

Note: Here “F” in Function is upper case.

[code type=html]
<html>
<head>
<script type=”text/javascript”>
document.onselectstart=new Function (“return false”)
</script>
</head>
<body>
Just  try to select this text.
</body>
</html>
[/code]

Disable History in Text box

Text box in webpage will store our previous entries. If textbox in our webpage having name same as some others webpage text box, then history of previous webiste will be shown in our webpage text box.

Disable history in text box means disable autocomplete

autocomplete=”off”

[code type=”html”]

<input type=”text” name=”Email” auto complete=”off”>

[/code]

 

Below text box will show history

<input type=”text” name=”Email”>

 

Below textbox won’t show the history

<input type=”text” name=”Email” auto complete=”off”>

One thought on “Disable Right Click and Copy in Webpage

  1. Abhilash Raj R S

    its a nice tutorial, we can use right click keyboard shortcut to open the menu. How we disable it ?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *