» Forums
» DynarchMenu forum
» Bug reports
» Shortcut keys open browser menu in IE
Shortcut keys open browser menu in IE
2005/03/25 00:12
Viewed 13267 times
Replies: 1/2

Yes, I know this is an IE bug and not the DTHML menu bug, but I believe I have a workaround for it (it annoyed me so much I had to do something :) and I thought I'd share it in case you would want to include it in distribution.
IE (and I only tested this with 6.0 on windows) seems to stop event propagation if the key in question is assigned as accesskey to a link (or a label). So the solution I found is to create empty <a href> element for each top-level menu item and assign menu item's shortcut key as accesskey for it.

The following code when added to createMenuItem() in hmenu.js (line 305 in library version) seems to do the trick:
if (is_ie && key) {
var blockingLink = document.createElement("A");
blockingLink.href = "#";
blockingLink.accessKey = key;
item.appendChild(blockingLink);
}

Thanks again for the excellent menu component.

Re: Shortcut keys open browser menu in IE
2005/03/25 22:06
Viewed 16527 times
Replies: 1/1

Hey there, thanks for the tip! :-) We were actually thinking about allowing keyboard navigation by using the "accesskey" attribute (instead of having the underscore thing as we do currently) and I think that in that case, this hack shouldn't be needed anymore--but however, we will add it for backwards compatibility.

last
Re[2]: Shortcut keys open browser menu in IE
2006/12/06 17:18
Viewed 9866 times
Replies: 0/0
by cfg

I noticed a different issue, the access key was being set to a space, so pressing alt+space in IE caused one of my menus to open, not the Window menu as expected. I use the keyboard to minimize windows, alt+space, n so this was kind of annoying.

if( is_ie && key && parent.base ) {
tmp = CE( "a", item );
tmp.href = "#";
+ key = key.replace( /\s+/, "" );
tmp.accessKey = key;
}
last
Google