Results 1 to 5 of 5

Thread: Modification for AnyLink Drop Down Menu

  1. #1
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Modification for AnyLink Drop Down Menu

    I'm using your AnyLink Drop Down Menu (http://www.dynamicdrive.com/dynamici...menuindex.htm).

    I need to display a pop-up menu when one of the drop-down links is clicked. I can do this easily enough by removing the "onClick" event from the main link description and adding it to the drop-down link's array description.

    The problem is that when the link is clicked, the "onClick" script is executed and then the "href" link is invoked. If I remove the "href" from the array description, it doesn't think its a link, and if I use href="" it displays a blank window on top of the pop-up window.

    Is there a way to modify the AnyLink script to not invoke the href link if its null (href="") or some other way to keep the script from executing the href?

    Thanks.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There are several ways to prevent an href from becoming activated when using an onclick event for its anchor element. The most straightforward is:

    Code:
    <a href="whatever.htm" onclick="dosomething();return false;">Link Text</a>
    where 'dosomething();' is your onclick function call or other onclick script code.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Hi John.

    I tried that, it doesn't work. Here's the array item descriptioin:

    GbMenu[0]='<a href="" target="_blank" onclick="showgb()";return false;>

    and here's the script I'm using to display the pop-up:
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function showgb() {
    var h=475
    var w=550
    var URL = "Gb.html";
    var windowprops = "height="+h+",width="+w+",location=no,top="+(screen.height-h)/2+",left="+(screen.width-w)/2+ "scrollbars=no,menubars=no,toolbars=no,resizable=no";
    popup = window.open(URL,"MenuPopup",windowprops); }
    // -->
    </script>

    Jim

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This is just wrong:

    Code:
    GbMenu[0]='<a href="" target="_blank" onclick="showgb()";return false;>
    It is so wrong, it is hard to imagine your intention for certain but, this is likely:

    Code:
    GbMenu[0]='<a href="#" onclick="showgb();return false;">'
    This is assuming that the showgb() function has no errors. If it has errors, the href will be loaded in the normal fashion.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    That worked. Thanks. I realize it was a dumb mistake, but we can't all be pros. I think I'll see if I can't find a script that displays tact. If I do, I'll send it on.

    Again, thank you for your assistance.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •