ContextMenu now supports Mozilla and Opera
I finished-off the changes required to make ContextMenu run in multiple-browsers and will be uploading the latest version of the control to GotDotNet tonight, so it should be available for download in 2-3 days - I'll blog a message when the new code is up and ready for download. So far I've tested it in:
- Internet Explorer 6
- Mozilla 0.7
- Opera 7.11
There's a demo page for ContextMenu which you can use to test the menu on your own browser; I'd appreciate any feedback via my contact form if you encounter bugs, etc.
It was certainly interesting making the changes to support all 3 browsers and I walked away thinking to myself that XBrowser scripting is no where near as difficult as it used to be now that the major browsers all support such rich functionality and support so many of the same standards and such.
Here is a description of some of the major changes that I had to make to my initial code to get it working in all 3:
Couldn't use attributes to store arbitrary pieces of information:
In my original control I was storing the LinkCommandArgument data as an attribute of the ANCHOR like so:
a commandArgument="1" href="javascript:void(0);" ...
Neither Opera nor Mozilla seemed to enjoy that because when I tried to reference that property like so:
// clickedItem is an object reference to the ANCHOR element and the commandArgument // reference off of that refers to the arbitrary attribute var args = new MenuItemClickedEventArgs( clickedItem.commandArgument ) ;
... 'undefined' was returned.
Positioning logic was incorrect:
The PositionCanvass method was using posLeft and posTop to move the layers around. Opera and Mozilla didn't seem to like that so I've changed over to just using "left" and "top":
this.Canvass.style.left = this.x ; this.Canvass.style.top = this.y ;
Slight Css alteration:
The Css for mozilla had to be changed so that I could get a thin black border around the outside of ContextMenu:
From
border: 1 black solid ;
To
border-width: 1px 1px 1px 1px; border-style: solid; border-color: black black black black;
There were also some miscellaneous errors which Internet Explorer had overlooked which had to be fixed - such as an extra comma which I had inserted into the jagged data arrays.