» Forums
» DynarchMenu forum
» Bug reports
» Menu remains highlighted after alert
Menu remains highlighted after alert
2005/10/10 22:35
Viewed 6182 times
Replies: 1/2

Browser: IE 6.0.2800.1106

We have implemented a Help->About menu that uses a simple javascript alert to pop up an "About Us" window. After clicking "OK", the "Help" menu remains highlighted; if you click on the Help menu it no longer responds until you click somewhere else.

I have created a test case for you (below); you may need to tweak it as appropriate. Simply open this up in IE, click Help menu and then select "About Us" menu item and observe. I tried to route my javascript through a separate function and use retval but that didn't work. Then I thought maybe I can obtain a reference to the "Help" menu and call setPressed(false) but that didn't work either. Please help!

<HTML>
<HEAD>

<style type="text/css">@import url("./hmenu/skin-xp-extended.css");</style>
<style type="text/css">@import url("./css/toolbar.css");</style>
<script type="text/javascript">_dynarch_menu_url = "./hmenu/";</script>
<script type="text/javascript" src="./hmenu/hmenu.js"></script>

<script type="text/javascript">

function initializeMenus()
{
menu = DynarchMenu.setup('menu', { shadows: [4, 6] });
hideMenus();
}

</script>

</HEAD>
<BODY onLoad="initializeMenus();">

<ul id="menu" style="display: none;">

<li id="File" title="_File">
_File
<ul>
<li id="1128966313825"><IMG SRC="help.png" BORDER="0"/><A HREF="javascript:alert('File New!');">New...</A></li>
</ul>
</li>

<li id="Help" title="_Help">
_Help
<ul>
<li id="1128966313826"><IMG SRC="help.png" BORDER="0"/><A HREF="javascript:alert('hello, world!');">About Us</A></li>
</ul>
</li>

</BODY>
</HTML>

Re: Menu remains highlighted after alert
2005/10/11 01:09
Viewed 7875 times
Replies: 1/1

There is a problem indeed with your approach.  The menu closes right after evaluating the JavaScript expression, but an “alert” dialog is modal (it stops the JS threads until the end user clicked on OK).

We hope to be able to make this easier in next versions, but for now here is a quick workaround:

<script type="text/javascript">
function displayAlert(message) {
setTimeout("alert('" + message + "')", 10);
}
</script>

[ ... ]

<ul id="menu">
[ ... ]
<li><a href="javascript:displayAlert('About us...')">About us</a></li>
</ul>

So as you can see, the idea is to delay the displaying of the alert by a short time (10 milliseconds).  During that time, the browser will get a chance to run the code that closes the menu.

I hope this helps.

last
Re[2]: Menu remains highlighted after alert
2005/10/11 13:00
Viewed 9572 times
Replies: 0/0

You guys game through again. That worked. Thanks!

last
Google