-
return false
I have oncontextmenu="return false;" and oncontextmenu="javascript:return false;" as attributes (it's a <TH> tag, incidentally, but I don't suppose it matters), and the resultant behaviour is satisfactory. However, when I have oncontextmenu="javascript:doThing();" along with
function doThing(){
return false;
}
I still get the context menu popping up.
Why is this, and how can I prevent it?
thanks,
S. Monkey (Mr)
-
:confused: The problem
(CORRECT) :
<elem onevent="return false;" />
(INCORRECT [where fooBar() returns false]) :
<elem onevent="fooBar();" />
:rolleyes: How browser parses
(CORRECT example [look above]):
<elem onevent="return false;" />
(INCORRECT example [look above]):
<elem onevent="false;" />
:eek: The solution
(INCORRECT example fixed to CORRECT):
<elem onevent="return fooBar();" />
Brief : you have to return the return value of the function to the object (element/tag in HTML).
-
context menu
try this
oncontextmenu="javascript:doThing();return false;"
on right click first call is to your function and the return false is for window's own context menu.
hope it works.. :-)
-
Hooray.
Thankyou, Zvona.
Good point, well made, works for me. My script is no longer Fubar'd.
Cheers muchly,
Surrendermonkey.