Attention: We are retiring the ASP.NET Community Blogs. Learn more >

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.

    View ContextMenu Demo

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.

9 Comments

  • The reason Mozilla didn't like your style to set the border is because it is not a valid style (it's not even valid in IE 6). You have to specify units in CSS, like so: border: 1px black solid;

  • What alternative did you come up with to solve the "attributes" issue? I find this "functionality" v. useful for all sorts of things.

  • I just ended up writing it out as a function argument instead; not my preferred way but {shrug} what can you do? So, instead of writing out:



    <a myCustomAttribute="foo" onclick="Blah(this)" ... />



    I wrote:



    <a onclick="Blah(this,'Foo')" ... />



    This meant that I had to change a "fair bit" of code to juggle the new argument.

  • Ну зачем про такое писать то.

  • может у кого нить есть ещё информация по этому поводу??

  • ou did a admissible chore creating a laws in behalf of the purpose photographers like me with no run including with stock. You explained so much that I needed to know. I con it with intense interest. You are a disparaging writer. I’m on uppermost of the everyone to occupy met you and skilled in that you are as advantageous and chummy as your farm indicates. Your keep from is appreciated.

  • чем отличается юмор от сатиры?
    картинки по строительству

  • Perhaps this gave someone the idea of mixing saltpetre
    and charcoal together and setting it alight. Do not take cold water bath
    immediately after a heavy work out, traveling, a long walk etc.
    Almost all the foods that they prepared were cooked in it.
    Breeding Sumatran rhinos in captivity has not been successful.

    A good variety for sushi is tuna, salmon, yellow fin, squid and eel.

  • In short, a good website hosting provider is not the one that offers cheap web hosting plans but one that deliver the best hosting services you
    need. if the hosting package includes the domain name registration,
    your overall cost of putting the website online can be lowered to larger extent.

    - Does it offer a quick and easy access to your log files.
    A web host is useful in setting up a secure and safe payment method for clients of
    a website. To help you decide on the type of package to avail yourself
    of, visit some review sites that feature the best affordable web hosting
    service providers out there.

Comments have been disabled for this content.