Results 1 to 5 of 5

Thread: Intercepting right-clicks in FireFox.

  1. #1

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Resolved 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;
    }
    Last edited by Disiance; May 19th, 2005 at 10:41 AM.
    "I don't want to live alone until I'm married" - M.M.R.P

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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
    My Blog.

    Ryan Jones.

  3. #3
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    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>

  4. #4

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Intercepting right-clicks in FireFox.

    thank you very much!
    "I don't want to live alone until I'm married" - M.M.R.P

  5. #5
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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
    My Blog.

    Ryan Jones.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width