Intercepting right-clicks in FireFox.
I have script that triggers off when the user right clicks in IE, but doesn't work in FireFox.
Code:
var whoami=navigator.userAgent.toLowerCase(); //use lower case name
var is_ie = (whoami.indexOf("msie") != -1); //does name contain 'msie'?
function setRClick(e) {
var message = "Right click disabled";
if(!document.rightClickDisabled) { // initialize
if(document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = setRClick;
}
else {
document.oncontextmenu = setRClick;
}
return document.rightClickDisabled = true;
}
if (is_ie) { //Internet Explorer
//This code to execute when right button is clicked
//Have taken out the "if (is_ie)" condition, that doesn't help, and makes it not work in IE
}
return false;
}
Re: Intercepting right-clicks in FireFox.
I don't think you an in Firefox in any case, there is an option to disallow scripts to control the right click, disable the scrollbar and things like that.
Cheers,
RyanJ
Re: Intercepting right-clicks in FireFox.
Perhaps there is an option to disallow script control of right clicks in FireFox..I use it but ain't that familiar with it...
Anywho, if they don't that option selected this script should do the trick - IE, NS, and works in my FireFox
Code:
<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>
Re: Intercepting right-clicks in FireFox.
Re: Intercepting right-clicks in FireFox.
Well, jut for reference it is in:
Tools >> Options >> Web Features >> (Accross fro the Enable Javascript Checkbox) Advanced >> And there is your advanced options including the ability to disable control over the right click menu :)
Cheers,
RyanJ