Adjust window's scroll position depending on which link clicked


E

Ethan

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
 
Ad

Advertisements

E

Evertjan.

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] ?
 
R

Richard Cornford

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

Advertisements

E

Ethan

Richard Cornford said:
<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top