Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-10-2010, 02:13 PM   PM User | #1
jmac726
New to the CF scene

 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jmac726 is an unknown quantity at this point
oncontextmenu window.event = null

I am trying to create a custom right-click menu in javascript, and I can't get the coordinates of the mouse when using oncontextmenu in IE7. I have it working fine in firefox, but in IE the window.event comes back as null.

Code:
checkbox.oncontextmenu = function(event) {
    if (event == null)
        event = window.event;
    
    alert("event: "+event);
    alert("window.event: "+window.event);

    /* Handle right-click */
};
I understand that IE does not pass along the event, but is there any reason why both of my alerts (specifically window.event) print null?
jmac726 is offline   Reply With Quote
Old 11-10-2010, 08:55 PM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,857
Thanks: 9
Thanked 288 Times in 284 Posts
Dormilich is on a distinguished road
calling your variable event could be troublesome, because event == window.event
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Reply

Bookmarks

Tags
event, ie7, null, oncontextmenu, window

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:03 PM.


Advertisement
Log in to turn off these ads.