Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Auto scrolling
- From: javascript@xxxxxxxxxx (Hassan Schroeder)
- Subject: [Javascript] Auto scrolling
- Date: Thu, 13 Feb 2003 12:54:26 -0800
Larry Cotton wrote:
> Hi
>
> I've written a contents page that displays/hides sub-section titles when
> you click on a section title. This is done by using the 'display' style
> property. The problem is whenever you 'open up' a list of sub sections
> the browser automatically scrolls to the top of the screen, so you have
> to scroll down to see the newly displayed sub sections.
>
> Does anyone know how to prevent this scrolling to the top ?
Yes -- don't tell it to :-)
Most browsers react to a non-existent anchor href ("#") by jumping
to the top of the page. Have your onclick function return false to
prevent the href target from being used:
<div id="Intro" style="display: '';" onClick="return(controlExpand(this, > 2));">
<a href="#" style="color: white; font-size: > 24pt;">Introduction</a></div>
function controlExpand(obj, noOfKids)
{
// actions deleted for brevity
return false;
}
HTH!
--
Hassan Schroeder ----------------------------- hassan@xxxxxxxxxxxxxx
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
- References:
- [Javascript] Auto scrolling
- From: Larry Cotton
- [Javascript] Auto scrolling
- Prev by Date: [Javascript] Auto scrolling
- Next by Date: [Javascript] why doesn't this work in IE 6 if it works fine in 5.5?
- Previous by thread: [Javascript] Auto scrolling
- Next by thread: [Javascript] Auto scrolling
- Index(es):