Connecting Tech Pros Worldwide Help | Site Map

Page "jumping" on link click

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 11:22 AM
Jim
Guest
 
Posts: n/a
Default Page "jumping" on link click

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, 11:22 AM
Matt Kruse
Guest
 
Posts: n/a
Default 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, 11:22 AM
Richard Cornford
Guest
 
Posts: n/a
Default 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, 11:23 AM
Jim
Guest
 
Posts: n/a
Default 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, 11:24 AM
Jimmy
Guest
 
Posts: n/a
Default 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]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.