Results 1 to 5 of 5

Thread: AnyLink and javascript functions instead of links

  1. #1
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default AnyLink and javascript functions instead of links

    Hi guys,

    I found your AnyLink scripts the other day, and love'em - but I'm looking to use them in a slightly different manner than 'normal'.

    In the drop-down menu, one item is a 'delete' function - and in the past, I've had this link tied to a JS function that has a confirm() in it - i.e. a 'You sure you want to delete this?' style bit.

    Now putting in "javascript:myDelFunction(x)" in the menu link array, instead of a normal URL, works fine up to a point. Hover over the menu, slide down to the item in question, click it - the confirm message comes up. And in IE 6, it works fine all the way through. But in Firefox (1.0.7 at least), after clicking the 'OK' confirm button, I get a JS error - 'b has no properties'. This seems to be in the function ' contains_ns6'. While trying to figure a workaround, I plopped in 'alert(b)' at the top of that function; when scrolling through the menu items, I'll get alerts with the contents of the link in question - but when clicking on my trouble menu item, the confirm comes up - I move the mouse off the menu to click 'OK' - and since I'm moving the mouse off the menu, the contains_ns6 function gets triggered again, and the alert comes up 'null'.

    Any thoughts on a workaround for this issue?

    Thanks much!

  2. #2
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Still looking for some help with this.

  3. #3
    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 is a way to avoid this error but, doesn't the script work fine in FF even with the error? Try this:

    Get rid of the alert(b) thing and close the javascript console.

    If you do this, does the script work OK?
    - John
    ________________________

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

  4. #4
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default It does and it doesn't.

    The trick is how you deal with the confirm popup. If you just hit the return key to say "OK", it's fine - because you're not moving your mouse away from the spot it was when you clicked on the drop-down menu item.

    But if you move the mouse away from where it was, and over the confirm popup - that's when things go blooey. It's at that point that the contains_ns6 function gets called again, and since the mouse isn't over any of the drop-down menu items, b is null, and the script fails.

    I'm going to look into trying to store the 'b' var contents elsewhere, in a temp var when the script gets called and there's something in it - and then when the script is called and b is null, to reference the temp var's value in its place...

  5. #5
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Well hot damn. That worked.

    So near the top of the script, I added:

    var tempB = '';

    and inside the contains_ns6 function, right off the bat:

    if (b == null) b = tempB;
    if (b != null) tempB = b;

    and it seems to have done the trick. Works like a charm in IE6 and FF1.0.7.

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
  •