Window scrolling (clarification)

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

    Window scrolling (clarification)

    This is a clarification of a previous message, which was not expressed
    very well. I have a set of checkboxes near the bottom of the page and
    a function that checks or unchecks all of them. But when the function
    runs, the window scrolls to the top of the page.

    How can I set my checkboxes but leave the window's scroll position
    exactly where it is? Or at least have it scroll to the bottom (where
    the checkboxes are).

    I've tried using window.scrollTo (), but the window always scrolls to
    the top no matter what. It's the same in Navigator and IE.

    Here's my code:

    function checkAll(whichF orm, startIndex, endIndex)
    {
    for (var j = startIndex; j <= endIndex; j++)
    {
    document.forms[whichForm].elements[j].checked = true;
    }
    window.scrollTo (0, 1000);
    }

    Thanks,

    Ethan
  • Fred Serry

    #2
    Re: Window scrolling (clarification)


    "Ethan" <elektrophyte@y ahoo.com> schreef in bericht
    news:55447041.0 307021144.4796d [email protected] gle.com...[color=blue]
    > This is a clarification of a previous message, which was not expressed
    > very well. I have a set of checkboxes near the bottom of the page and
    > a function that checks or unchecks all of them. But when the function
    > runs, the window scrolls to the top of the page.
    >
    > How can I set my checkboxes but leave the window's scroll position
    > exactly where it is? Or at least have it scroll to the bottom (where
    > the checkboxes are).
    >
    > I've tried using window.scrollTo (), but the window always scrolls to
    > the top no matter what. It's the same in Navigator and IE.
    >
    > Here's my code:
    >
    > function checkAll(whichF orm, startIndex, endIndex)
    > {
    > for (var j = startIndex; j <= endIndex; j++)
    > {
    > document.forms[whichForm].elements[j].checked = true;
    > }
    > window.scrollTo (0, 1000);
    > }
    >
    > Thanks,
    >
    > Ethan[/color]

    Hi,

    Can you show how this function is called? I suspect you are using something
    like:

    <a href="#" onclick="checkA ll(blabla)">

    If so, add a "return false" to prevent the link to do its actual work

    <a href="#" onclick="checkA ll(blabla);retu rn false">

    Fred


    Comment

    • Ethan

      #3
      Re: Window scrolling (clarification)

      "Fred Serry" <fred.NOSPAM.se [email protected]> wrote in message news:<bdvdne$11 [email protected] cis.de>...[color=blue]
      > "Ethan" <elektrophyte@y ahoo.com> schreef in bericht[/color]
      ....[color=blue][color=green]
      > > How can I set my checkboxes but leave the window's scroll position
      > > exactly where it is? Or at least have it scroll to the bottom (where
      > > the checkboxes are).
      > >
      > > I've tried using window.scrollTo (), but the window always scrolls to
      > > the top no matter what.[/color][/color]
      ....[color=blue]
      > Hi,
      >
      > Can you show how this function is called? I suspect you are using something
      > like:
      >
      > <a href="#" onclick="checkA ll(blabla)">
      >
      > If so, add a "return false" to prevent the link to do its actual work
      >
      > <a href="#" onclick="checkA ll(blabla);retu rn false">
      >
      > Fred[/color]

      That's the answer. Thank you very much.

      Ethan

      Comment

      Working...