This question is more of a Javascript question, but I figure fellow
AJAX users have probably come across this long before I have. I'm
trying to create a small context popup on the page when the user right
clicks the page. The context menu is a simple table hidden on the
screen that is moved to the user's cursor and displayed. My audience
is 100% I.E. so cross-browser compatibility isn't as important as it
would be on an externtal web page.
The problem I'm having is I cannot stop the default right-click action
in IE which displays the full IE context menu. The following code
cancels the event *only* if I put an alert() in it at some point, even
with the cancelBubble() and returnValue() functions.
<script language="javascript">
function CheckButton(evt)
{
var button = event.button;
switch (button)
{
case 2:
MoveContextBox();
evt.cancelBubble = true;
evt.returnValue = false
break;
case 1:
alert("Button 1!");
break;
default:
break;
}
event.cancelBubble = true;
event.returnValue = false
return false;
}
</script>
<table>
<tr onclick="CheckButton()">
<td>1</td>
<td>2</td>
</tr>
</table>
Have you run across this before and is there a fix for it?
Thanks!
R
Oops, the table event should be:
<table>
<tr onmouseup="CheckButton()">
<td>1</td>
<td>2</td>
</tr>
</table>
-----------------------------------------------Reply-----------------------------------------------
You need to return false with the oncontextmenu
Eric
On 2/28/07, RisingFish <risingf@gmail.com> wrote:
> Oops, the table event should be:
> <table>
> <tr onmouseup="CheckButton()">
> <td>1</td>
> <td>2</td>
> </tr>
> </table>