Show popup window with a JavaScript onClick call

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Steel2k6
Beginner
Beginner
Posts: 6
Joined: Tue Nov 15, 2005 1:18 pm

Show popup window with a JavaScript onClick call

Post by Steel2k6 »

Hi!

I would like to show a popup window when I click on a link. For some reason, this does not work. But it works when I call this function on a onMouseOver event for a link. Strange...

So, this works fine:
<a href='#' onMouseOver='popup( "workout",1 );' class='weekCalendarLink' id='entry_1_1'>9:30<br>Workout</a>

This does not work:
<a href='#' onClick='popup( "workout",1 );' class='weekCalendarLink' id='entry_1_1'>9:30<br>Workout</a>

Do you know why or how I could solve this problem? The live page can be found at http://www.get-up-fitness.de/wintercourseplan.aspx .

Thanks!
Steel2k6
Beginner
Beginner
Posts: 6
Joined: Tue Nov 15, 2005 1:18 pm

Post by Steel2k6 »

Milonic team, please help. I saw that this question has been asked a few days ago from another user:

viewtopic. ... ight=popup
Steel2k6
Beginner
Beginner
Posts: 6
Joined: Tue Nov 15, 2005 1:18 pm

Post by Steel2k6 »

For everybody who has the same problem and does not want to wait for the answer, this can be used as a workaround:

function initPopup( menuName )
{
setTimeout( "showPopup('" + menuName + "')", 1 );
}
function showPopup( menuName )
{
popup( menuName, 1 );
}

<a href='#' onClick='initPopup( "workout" );' class='weekCalendarLink' id='entry_1_1'>9:30<br>Workout</a>
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Hi,

What's happeing is the page is being reloaded because of the href=# bit when you click on the link. The menu is probably showing up but it gets refreshed so you never see it.

You need to replace the href="#" with href="javascript:popup('yourmenu','yourimage')" - This will mean that the link is the javascript popup function executor rather than an actual lnk.

Hope this helps,
Andy
Steel2k6
Beginner
Beginner
Posts: 6
Joined: Tue Nov 15, 2005 1:18 pm

Post by Steel2k6 »

Hi Andy,

thank you very much, this works great!
Post Reply