| re: Window scrolling (clarification)
"Ethan" <elektrophyte@yahoo.com> schreef in bericht
news:55447041.0307021144.4796d248@posting.google.c om...[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(whichForm, 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="checkAll(blabla)">
If so, add a "return false" to prevent the link to do its actual work
<a href="#" onclick="checkAll(blabla);return false">
Fred |