How to Prevent Right Clicking in Firefox
When using Firefox or other Web browsers, visitors of your website can perform a variety of actions by right clicking on your Web page. This includes downloading images by using the "Save Image As" command, or viewing the HTML code you used to create your website by using the "View Page Source" command. Disabling the right click function on your website is the only way to prevent people from being able to right click on your Web page in the Firefox browser.
Instructions
-
With Alert
-
1
Open inside an HTML or text editor --- such as Notepad --- the HTML code for the page that you want to disable right clicking on.
-
2
Locate the <body> tag within the code.
-
-
3
Copy the following code, and paste it right beneath the <body> tag:
<script language=JavaScript>
<!--
var message="Function Disabled!";
///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// -->
</script>
-
4
Save the changes to the HTML code, and exit the HTML or text editor.
-
5
Re-upload the HTML code to your website, if necessary for the changes to take effect.
-
6
Navigate to your website in the Firefox browser, and try to use the right click function to test that it has been disabled.
Without Alert
-
7
Open inside an HTML or text editor --- such as Notepad --- the HTML code for the page that you want to disable right clicking on.
-
8
Locate the <body> tag within the code.
-
9
Copy the following code, and paste it right beneath the <body> tag:
<script language=JavaScript>
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</script>
-
10
Save the changes to the HTML code, and exit the HTML or text editor.
-
11
Re-upload the HTML code to your website, if necessary for the changes to take effect.
-
12
Navigate to your website in the Firefox browser, and try to use the right click function to test that it has been disabled.
-
1
References
- Photo Credit Ciaran Griffin/Stockbyte/Getty Images