Adjust window's scroll position depending on which link clicked

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ethan

    #1

    Adjust window's scroll position depending on which link clicked

    I have a form that contains sets of checkboxes. Each set has links
    above it marked "Check all" and "Uncheck all". The links call
    JavaScript functions.

    Here's the problem. When you click "Check all" and it's near the
    bottom of the page, the page is RELOADED and the user winds up looking
    at the top of the page. Sure, all the boxes are properly checked, but
    now the user has to scroll back down to where they were before.

    It's easy enough to use the window.scrollTo () function, but because of
    setting the checkboxes the document is reloaded, so the scrollTo()
    function is useless. It scrolls down, but when the document is
    reloaded, it instantly pops back up to the top.

    Any solutions?

    Thanks,

    Ethan
  • Evertjan.

    #2
    Re: Adjust window's scroll position depending on which link clicked

    Ethan wrote on 02 jul 2003 in comp.lang.javas cript:
    [color=blue]
    > I have a form that contains sets of checkboxes. Each set has links
    > above it marked "Check all" and "Uncheck all". The links call
    > JavaScript functions.
    >
    > Here's the problem. When you click "Check all" and it's near the
    > bottom of the page, the page is RELOADED and the user winds up looking
    > at the top of the page. Sure, all the boxes are properly checked, but
    > now the user has to scroll back down to where they were before.
    >[/color]

    Why should the page reload, [exept if you submit a form] ?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Richard Cornford

      #3
      Re: Adjust window's scroll position depending on which link clicked

      "Ethan" <elektrophyte@y ahoo.com> wrote in message
      news:55447041.0 307021119.53fe8 e1d@posting.goo gle.com...
      <snip>[color=blue]
      >Here's the problem. When you click "Check all" and it's near
      >the bottom of the page, the page is RELOADED and the user
      >winds up looking at the top of the page. Sure, all the boxes
      >are properly checked, but now the user has to scroll back down
      >to where they were before.[/color]
      <snip>

      Return false from the onclick code to cancel the navigation specified in
      the HREF.

      Richard.

      --

      Example JavaScript DOM listings for: Opera 7.11,
      Mozilla 1.2 and ICEbrowser 5.4
      <URL: http://www.litotes.demon.co.uk/dom_root.html >


      Comment

      • Ethan

        #4
        Re: Adjust window's scroll position depending on which link clicked

        "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message news:<bdvj5q$t0 r$1$8300dec7@ne ws.demon.co.uk> ...[color=blue]
        > "Ethan" <elektrophyte@y ahoo.com> wrote in message
        > news:55447041.0 307021119.53fe8 e1d@posting.goo gle.com...
        > <snip>[color=green]
        > >Here's the problem. When you click "Check all" and it's near
        > >the bottom of the page, the page is RELOADED and the user
        > >winds up looking at the top of the page. Sure, all the boxes
        > >are properly checked, but now the user has to scroll back down
        > >to where they were before.[/color]
        > <snip>
        >
        > Return false from the onclick code to cancel the navigation specified in
        > the HREF.
        >
        > Richard.[/color]

        That solved the problem thanks.

        I made a mistake before -- the page is not reloaded. It just scrolled to the top.

        For the record, here's the way to set it up so that it works right...

        <a href="#" onclick="unchec kAll(0, 68, 75); return false;">

        Ethan

        Comment

        Working...