• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bemused event question

 
Graham VMead
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be a totally stupid question, I'm not a javascript expert but I wonder if someone could elighten me on something.

I'm trying to use the <SCRIPT FOR = object EVENT = oncontextmenu> construct in IE.

Now you can specify <body oncontextmenu="myfunction()"> in HTML and the MSDN Link seems to me to imply that oncontextmenu is an event associated with the body object so naively I assumed

<SCRIPT FOR = document.body EVENT = oncontextmenu> would work! Does it %&*"! you have to use <SCRIPT FOR = document EVENT = oncontextmenu>

Similarly you can specify onunload in an HTML <BODY> tag but you have to use <SCRIPT FOR = window EVENT = onunload> to get it to work!!! I know one is a tag and the other a DOM object but I expected some sort of correlation.

Am I missing a piece of wondrous logic somewhere, how do I work out which DOM object I should use, i.e the one that initiates the event/gets the event bubbled to it???

Thanks to anyone who can shine some light on this

Graham
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My only advice would be to avoid the IE-only proprietary mechansims and limit yourself to W3C standards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic