JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 1st, 2007, 01:34 PM
kotharavi kotharavi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 5 kotharavi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m 6 sec
Reputation Power: 0
Question How to disable right click in Firefox

Frnds,

How can I disable right click in Firefox. Iam using SVG in my application. So, when user right click on SVG area the default menu needs to be disabled and my own created menu should be displayed. I am able to do that in IE. The same code is not working for Firefox. Can somebody tell me how to disable it for Firefox? Here is the code iam using.

Code:
function rightClick(evt) {
    showTooltip(evt, false);
    evt.preventDefault();
    evt.stopPropagation();
    var nodeID = DragTarget.getAttributeNS(null, "id");
    top.rightClickMenu(nodeID, gStage);
}

Waiting for some reply////

Reply With Quote
  #2  
Old February 1st, 2007, 06:45 PM
mecanicu mecanicu is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 112 mecanicu User rank is Private First Class (20 - 50 Reputation Level)mecanicu User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 3 h 23 m 6 sec
Reputation Power: 3
P.s.

Try this one:

Code:
var message="Right-mouse click has been disabled.";
function click(e)
{
  if (document.all)
  {
    if (event.button==2||event.button==3)
    {
      alert(message);
      return false;
    }
  }
  else
  {
    if (e.button==2||e.button==3)
    {
      e.preventDefault();
      e.stopPropagation();
      alert(message);
      return false;
    }
  }
  if (e.which)
  {
    alert("oops Opera?")
  }
}

if (document.all) // for IE
{
  document.onmousedown=click;
}
else // for FF
{
  document.onclick=click;
}


Be careful, Opera browser has an option in preferences where the right-click must be enabled. You can not modify this option from the web site.

Your code for menu goes in the places with alert(message)

Hope this will help

Last edited by mecanicu : February 1st, 2007 at 06:48 PM. Reason: forgot

Reply With Quote
  #3  
Old February 1st, 2007, 08:34 PM
kotharavi kotharavi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 5 kotharavi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m 6 sec
Reputation Power: 0
Thanks mecanicu

Thank you very much. I have tried this and right click is disabled for Firefox. But your code is not working in IE. Basically, the IF condition for IE is not working.

Code:
if (document.all) // for IE
{
alert('explorer');
document.onmousedown=rightClick;
}


This IF is not checking for IE. Anyways thankyou very much once again.

Reply With Quote
  #4  
Old February 2nd, 2007, 11:53 AM
kotharavi kotharavi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 5 kotharavi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m 6 sec
Reputation Power: 0
Created menu is not in right position

Hi,

Using the above code Iam able to disable the right click in FF. But the menu I created in SVG is not in showing at the point where I right clicked. It randomly placing the menu somewhere in the window. Can somebody help me out in this. Thanks,

Reply With Quote
  #5  
Old February 24th, 2007, 04:43 AM
Psycho77 Psycho77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 4 Psycho77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 48 sec
Reputation Power: 0
Javascript to disable right click in IE & Firefox

Hi there,

I hope the code below works for you.
The Javascript code is to disable right-click in both Internet Explorer & Firefox. Best Regards!

Code:
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")

Reply With Quote
  #6  
Old December 20th, 2007, 08:54 PM
andysibs andysibs is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 1 andysibs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 37 sec
Reputation Power: 0
hi, the first code seemed to work well for me, except was showing the 'oops opera' message, every time you clicked anywhere on a mac.

any suggestions?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > How to disable right click in Firefox


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT