One of my many side projects is to create scripting libraries and components so that one doesn't have to rely on ActiveX as much as they do now for functionality. To steal the term from Brendan Eich "DeCOMtamination" is the goal. Heres the first component I'd like to share that was adapted and updated from an old script I found undocumented in the MSDN archive around the year 2000:
A menu bar for your HTA projects:
Your html page is as simple as this:
What I've done is create a custom HTML tag called (obviously) <TNO:jsmenu>.By looking at this code you can see how easy it is to add and take away menu items. At the top of the document you'll notice three things: First, <HTML xmlns:TNO> which defines the name of my custom Tag. Second,<?IMPORT namespace="TNO" implementation="jsmenu.htc"> which defines what code is going to make that tag work. Third, <script type="text/javascript" src="menufunction.js"></script> which tells the menu what functions to use when I click on a menu item.
The js file is simple menufunction.js:
All this does is call the functions I really want to use for each menu item.
And finally the back-end engine that does all the work, The HTML Component file (jsmenu.htc):
I'll let the inline comments explain themselves.
To see a live example of this in action, you can see it here:
I've been working on a vbscript equivalent, but haven't had any success yet. Event Listeners are causing me headaches. Perhaps one of you master vbscripters can come up with a translation. If so I would gladly host it for the indefinate future. (All credit due of course).
Stay tuned, in the works: Context menu for your mouse. Cross Platform File browser that relies only on WSH and an HTA A Combo Box (Just like the address bar of the browser) A Splash Screen (For that professional look) A Table with a frozen header and left column just like EXCEL
Ahhhhhhh....HTA menus. Bring back memories of the early ManagePC days.
I used the Milonic menu system which is written in Jscript and is incredibly customisable. I stumbled across the same problem with event handlers as you though. Just couldn't get them to work