Connecting Tech Pros Worldwide Help | Site Map

Page "jumping" on link click

Jim
Guest
 
Posts: n/a
#1: Jul 23 '05
Hey guys
I have this page that uses a small script that changes the button image
when the button is clicked. The problem is that when clicked, the page
suddenly "jumps" to the top. I have purposly left dead links in the page
(the ones that "point" to the page the viewer is currently on). Is there
a way to stop this behaviour? Also, I have created a remote rollover
effect so that when the cursor is over a button, an image in another
location changes. But the image that is supposed to load, takes a while
to do so and the whole effect is ruined. The image size is logical but
is there any way to load them into the browsers cache in the background?
Thanks!

Jim
Matt Kruse
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Page "jumping" on link click


Jim wrote:[color=blue]
> I have this page that uses a small script that changes the button
> image when the button is clicked. The problem is that when clicked,
> the page suddenly "jumps" to the top. I have purposly left dead links
> in the page (the ones that "point" to the page the viewer is
> currently on). Is there a way to stop this behaviour?[/color]

I assume you are using onClick in the <a> tag?
Make sure to return false.
<a href="whatever.html" onClick="func();return false;">link</a>

When reporting a problem, it's always helpful to include your exact code
example that is failing, or even better a link to the page itself.
[color=blue]
> The image size is logical but is there any way to load them
> into the browsers cache in the background? Thanks![/color]

Yes, look into any common image rollover script for how to create Image()
objects which will (hopefully) pre-cache your images.

--
Matt Kruse
Javascript Toolbox: http://www.mattkruse.com/javascript/


Richard Cornford
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Page "jumping" on link click


Jim wrote:[color=blue]
> I have this page that uses a small script that changes the button
> image when the button is clicked. The problem is that when clicked,
> the page suddenly "jumps" to the top.[/color]
<snip>

Failure to return false form the onclick event handler to cancel
navigation, combined with using "#" as an HREF (which is interpreted as
the URL of the top of the current page (usually)).

Richard.


Jim
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Page "jumping" on link click


Thanks for the tips Matt, I will follow your advice in the future
regarding the code. Just for the sake of it, the page url is this:
www.team-x.gr/products.htm
Thanks again!

Matt Kruse said the following on 06/03/04 16:40:[color=blue]
> Jim wrote:
>[color=green]
>>I have this page that uses a small script that changes the button
>>image when the button is clicked. The problem is that when clicked,
>>the page suddenly "jumps" to the top. I have purposly left dead links
>>in the page (the ones that "point" to the page the viewer is
>>currently on). Is there a way to stop this behaviour?[/color]
>
>
> I assume you are using onClick in the <a> tag?
> Make sure to return false.
> <a href="whatever.html" onClick="func();return false;">link</a>
>
> When reporting a problem, it's always helpful to include your exact code
> example that is failing, or even better a link to the page itself.
>
>[color=green]
>>The image size is logical but is there any way to load them
>>into the browsers cache in the background? Thanks![/color]
>
>
> Yes, look into any common image rollover script for how to create Image()
> objects which will (hopefully) pre-cache your images.
>[/color]
Jimmy
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Page "jumping" on link click


Oups, forgot to thank Richard for his advice. I just saw his post today.
Thanks guys

Richard Cornford wrote:[color=blue]
> Jim wrote:
>[color=green]
>>I have this page that uses a small script that changes the button
>>image when the button is clicked. The problem is that when clicked,
>>the page suddenly "jumps" to the top.[/color]
>
> <snip>
>
> Failure to return false form the onclick event handler to cancel
> navigation, combined with using "#" as an HREF (which is interpreted as
> the URL of the top of the current page (usually)).
>
> Richard.
>
>[/color]
Closed Thread