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

Adjust window's scroll position depending on which link clicked

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


P: n/a
Ethan wrote on 02 jul 2003 in comp.lang.javascript:
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.


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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a
"Ethan" <el**********@yahoo.com> wrote in message
news:55**************************@posting.google.c om...
<snip>
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.

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

P: n/a
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message news:<bd*******************@news.demon.co.uk>...
"Ethan" <el**********@yahoo.com> wrote in message
news:55**************************@posting.google.c om...
<snip>
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.

<snip>

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

Richard.


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="uncheckAll(0, 68, 75); return false;">

Ethan
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.