Forum Moderators: open

Message Too Old, No Replies

Script Always Jumps To Top

         

Fess

7:52 am on Nov 14, 2004 (gmt 0)

10+ Year Member



Hello,

I've been using the script below for some time now & have just noticed a quirk.

Whenever the link(s) are clicked, the original page ZOOMS back up top.

Why is this happening? How do I remove that bug?

Any Advice is appreciated
Regards
Fess

[quote]<script language="JavaScript">

function GetRandom(start,end)
{
var range = end - start + 1;
var result = start + Math.floor(Math.random()*range);
return result;
}

function getRandomLink(whichSet) {
contentlinks = new Array("http://www.example.com/",
"");

trafficlinks = new Array("http://www.example.com/",
"");

if (whichSet==0) { window.open(contentlinks[GetRandom(0,contentlinks.length-1)]) }
else if (whichSet==1) { window.open(trafficlinks[GetRandom(0,trafficlinks.length-1)]) }

}

</script>[quote/]

[edited by: rogerd at 1:38 pm (utc) on Nov. 14, 2004]
[edit reason] No URLs please... [/edit]

Bernard Marx

2:18 pm on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not a bug.
I'm guessing that you are using something like:

<a href="#" onclick="blah();return false;">

# means "go to anchor [page top]".
Add the code in red, and hopefully it won't do that anymore.

Fess

9:10 pm on Nov 14, 2004 (gmt 0)

10+ Year Member



Bernard,

Good to hear from you buddy. If you recall this thread, you'll remember me:

[webmasterworld.com...]

Your suggestion worked perfectly. Thanks!

P.S. sorry about the url in the above post. Slipped my mind.

Regards
Fess

Bernard Marx

9:19 pm on Nov 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I do mate. I recognised the arrays.