Connecting Tech Pros Worldwide Help | Site Map

Page "jumping" on link click

  #1  
Old July 23rd, 2005, 12:22 PM
Jim
Guest
 
Posts: n/a
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
  #2  
Old July 23rd, 2005, 12:22 PM
Matt Kruse
Guest
 
Posts: n/a

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/


  #3  
Old July 23rd, 2005, 12:22 PM
Richard Cornford
Guest
 
Posts: n/a

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.


  #4  
Old July 23rd, 2005, 12:23 PM
Jim
Guest
 
Posts: n/a

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]
  #5  
Old July 23rd, 2005, 12:24 PM
Jimmy
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
aPossible to Make A "Dummy" Anchor Tag **without** Jumping Back Up??? Prisoner at War answers 16 June 27th, 2008 08:18 PM
aPossible to Make A "Dummy" Anchor Tag **without** Jumping Back Up??? Prisoner at War answers 21 June 27th, 2008 08:15 PM
aPossible to Make A "Dummy" Anchor Tag **without** Jumping Back Up??? Prisoner at War answers 20 June 27th, 2008 08:10 PM
<a href="#raleigh">Raleigh NC</a> Jim Carlock answers 3 March 7th, 2006 07:45 PM