Disable context menu and text selection in browser

Disable context menu and text selection in browser

When you build websites you do not always want visitors to be able to use the context menu or to be able to select the text from the site. To disable the context menu add to following code to the <body> tag of your website:

[html]
<body oncontextmenu=’return false’>
[/html]

To disable text selecting, add the following code to the <body> tag:

[html]
<body ondragstart=’return false’ onselectstart=’return false’>
[/html]

Take into consideration that not all browsers support these features.

Leave a Reply

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