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, 12: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, 05:45 PM
mecanicu mecanicu is offline
anonymous
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 244 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: 1 Week 12 h 21 m 10 sec
Reputation Power: 12
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 05:48 PM. Reason: forgot

Reply With Quote
  #3  
Old February 1st, 2007, 07: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, 10: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, 03: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, 07: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
  #7  
Old October 1st, 2009, 02:14 PM
adderek adderek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 2 adderek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 2 sec
Reputation Power: 0
Stupid idea

Why you want to block users from right-click? Maybe you would like to disable mouse and keyboard support as well?

I'm using gestures under right-click. I'm using right-click menu for navigation. When I find a page that forbids right-click I add it to blocked sites.
Some sites I really want to use - then I am fighting with scripts like that - by blocking the ability to block the right-click.

Does it add any security? I can easily copy any content from such webs. Install chrome or firefox or maxthon and then drag'n'drop the picture - works perfectly.
You can use browsers cache to get the picture. You can check the web's source to find the URL of the picture. You can use automatic-download-addons for browsers. There are more ways of copying the images.

Again: Why do you want to make the user crippled?
If you are reading this and going to use such script - knock yourself in your head and think again if that is what you want to do. If you really do then use huge flash animation instead of web content and make it full screen. And add a horn sound. Maybe a virus as well.... Yes - that is something that some web developers would love to do - or at least it looks so.

Sorry for excessive criticism but the criticism is well earned in that case.

Reply With Quote
Reply

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


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap