By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Window scrolling (clarification)

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Ethan" <el**********@yahoo.com> schreef in bericht
news:55**************************@posting.google.c om...
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


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
Jul 20 '05 #2

P: n/a
"Fred Serry" <fr***************@planet.nl> wrote in message news:<bd*************@ID-108377.news.dfncis.de>...
"Ethan" <el**********@yahoo.com> schreef in bericht ....
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.

.... 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


That's the answer. Thank you very much.

Ethan
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.