Page "jumping" on link click

Discussion in 'Javascript' started by Jim, Jun 3, 2004.

  1. Jim

    Jim Guest

    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
    Jim, Jun 3, 2004
    #1
    1. Advertising

  2. Jim

    Matt Kruse Guest

    Jim wrote:
    > 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?


    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.

    > The image size is logical but is there any way to load them
    > into the browsers cache in the background? Thanks!


    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/
    Matt Kruse, Jun 3, 2004
    #2
    1. Advertising

  3. Jim wrote:
    > 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.

    <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.
    Richard Cornford, Jun 3, 2004
    #3
  4. Jim

    Jim Guest

    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:
    > Jim wrote:
    >
    >>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?

    >
    >
    > 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.
    >
    >
    >>The image size is logical but is there any way to load them
    >>into the browsers cache in the background? Thanks!

    >
    >
    > Yes, look into any common image rollover script for how to create Image()
    > objects which will (hopefully) pre-cache your images.
    >
    Jim, Jun 4, 2004
    #4
  5. Jim

    Jimmy Guest

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

    Richard Cornford wrote:
    > Jim wrote:
    >
    >>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.

    >
    > <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.
    >
    >
    Jimmy, Jun 5, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anonymous

    page editor: jumping in virtual space

    Anonymous, Sep 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    342
    Anonymous
    Sep 8, 2005
  2. Merlin
    Replies:
    2
    Views:
    344
    Ed Seedhouse
    Oct 14, 2006
  3. jalkadir
    Replies:
    3
    Views:
    413
    jalkadir
    Oct 5, 2005
  4. Anonymous

    page editor: jumping in virtual space

    Anonymous, Sep 8, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    103
    Anonymous
    Sep 8, 2005
  5. Udo Huebner
    Replies:
    22
    Views:
    1,036
    Udo Huebner
    Feb 2, 2012
Loading...

Share This Page