|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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//// |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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, |
|
#5
|
|||
|
|||
|
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")
|
|
#6
|
|||
|
|||
|
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? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > How to disable right click in Firefox |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|