Click to See Complete Forum and Search --> : Forcing a scroll


Webskater
04-02-2003, 04:26 AM
Can anyone tell me how, when someone clicks a link, it forces the focus onto a control and then scrolls the page so that that control is at the top of the page. Thanks.

gil davis
04-02-2003, 06:16 AM
<a href="#t1" onclick="document.f1.t1.focus()">Click</a>
...
<form name="f1" onsubmit="return false">
<input name="t1" type="text">
</form>If the page is sufficiently big, this will "scroll" to the top. Otherwise, it will just scroll into view. Either way, the field gets focus.