View Full Version : AnyLink and javascript functions instead of links

10-18-2005, 02:32 PM
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!

11-02-2005, 05:41 PM
Still looking for some help with this.

11-02-2005, 06:11 PM
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?

11-04-2005, 04:38 PM
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...

11-04-2005, 04:44 PM
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.