Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why simple function won't work without alert() 1

Status
Not open for further replies.

lwfg

Programmer
Feb 9, 2009
52
0
0
US
Why does a() stop right clicks but b() doesn't ?

function a(e)
{
if (event.button==2)
{
alert('No right click please.');
return false;
}
}
document.onmousedown=h

function b(e)
{
if (event.button==2)
return false;
}
document.onmousedown=h
 
because it is the alert() that stops it.

the alert box is a modal dialog which halts processing until a response is returned.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Hi

Chris said:
the alert box is a modal dialog which halts processing until a response is returned.
So this is the code which usually displays an [tt]alert()[/tt] before the context menu appears ? So lame attempt to stop me that I never took a look at its code.

lwfg, unless you wan to do something constructive on secondary click ( like marking bombs in a Minesweeper game ), better give up. Such attempts just annoy the visitors, not stop them to right click.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top