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

Contents tagged with Javascript

  • Wanna use goto? You could break STUFF!

    Today while writing a javascript version of a parser I was trying to work out how to implement a goto statement so that I could break out of an outer loop from an inner loop. You can either break or continue a labelled statement. The following snippet breaks a labelled statement.

  • 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.

  • Adding cross-browser support for ContextMenu

    This weekend I have to get the ContextMenu working in Opera and Mozilla browsers. This shouldn't be too hard as I've stuck close to the spec. on everything and already have a browser sniffer built in to the js code. I've already taken the precautions of separating the 4 main XBrowser fragile parts out into their own logic units:

  • ContextMenu - now working in browser.

    I finally got all of the rendering logic finished and spent this morning working "in the client" on some positional bugs. Basically, I had the menu working fine until the user selected a menu which was at a position greater the 1 window height down the page. In other words, if the page was tall enough to require a scrollbar down the side, the positioning of the menu was screwy when you had to scroll down. I've fixed that though with a nice little hack :-) Basically, I wire-up a delegate to handle the mousedown event on the document like so:

  • Minimize string creation in dhtml widgets

    I wrote a component tonight which allows me to easily bind client-side pop-up menu's to objects on a web page.  A single menu is basically a Html TABLE with a collection of child menu-items represented by DIV's.  Because there is a high liklehood of menu's being created over and over again I decided that I would take steps to minimize the amount of string building by “caching” the html for the menu and each menu-item the first time that it is generated.  I liked it so much that I thought I'd blog it :-)  Here is the GetHtml method for the menu which caches it's chunk of Html in the array variable named _stringIntern_ the first time that it is generated and pulls it from there on subsequent rendering operations.  The same logic is followed for each menu-item.