Welcome to WebmasterWorld Guest from 18.208.159.25

Forum Moderators: open

Message Too Old, No Replies

href="javascript:;" problem

     
7:35 pm on Dec 9, 2003 (gmt 0)

New User

10+ Year Member

joined:July 3, 2003
posts:26
votes: 0


Using the following code for a simple rollover (okay, it's Dreamweaver, i'm getting lazy in my old age)

<a href="javascript:;" onMouseOver="MM_swapImage('colorRollTop','','images/top_white420c.jpg',1)">

What happens, is that on slow connections, it seems that a 'click' by the user is blocking the rollover from happening. Almost like it tries to fire the javascript:; and stops processing the rollover? Can this be the case?

Even with onClick i've seen the rollover not load as well, seems to be the same issue. Could it be the javascript:; (the null href)? Is there another option for this I don't know about?

p.s. I can get around the issues using href="named_anchor", but this isn't ideal. Using <a name...> instead of href works too, but not in OLD NN4 browsers. It definitely seems to be the link click that is the problem (as losing the href tag solves it). Other tags like <span> work fine too, but not in NN4. I guess I need to find a way of triggering the rollover in NN4 that doesn't involve the javascript:; null href?

karembeu

9:37 pm on Dec 9, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 17, 2001
posts:1262
votes: 0


A wild guess:

Are you prefetching the images? If not then yes, it is entirely possible that the user clicks on the link and the browser attempts to follow it before it has time to load the rollover image-- effectively canceling the rollover. On a slow machine, I suspect it would be true even if you were attempting to preload the images, if they were large, so maybe you could prefetch in the <head> instead of with a body onLoad as Dreamweaver seems to like.

Instead of javascript:; you could also try javascript:void(0); or # , both of which work in NN4.

1:27 pm on Dec 10, 2003 (gmt 0)

New User

10+ Year Member

joined:July 3, 2003
posts:26
votes: 0


the # doesn't work for me as it jumps to the top of the page.
7:13 pm on Dec 10, 2003 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4061
votes: 0


Use the Void.

<a href="javascript:void(0)" onClick="blah()">

The void(0) function never interferes with any other mouse events. It's a good one.