[Javascript] Window.scroll

Paul Novitski paul at novitskisoftware.com
Thu Jul 8 11:14:51 CDT 2004


At 04:29 PM 7/7/2004, dev at qroute.net wrote:
>When setting the focus to a form object, window automatically moves to that
>location. But, I would like the browser window to go about 75Px higher so
>The caption of that object can be visible too.
>
>How do I do that ?
>window.scrollto = window.scroll - 75 ??


Here's a funky solution that might work cross-browser because it's so low-tech:

         <input id="WhereYouWantFocus" ...>
         <p>caption</p>
         <a id="SendFocusHereFirst"></a>

         function FocusOnInput()
         {
                 document.getElementById("SendFocusHereFirst").focus();
                 document.getElementById("WhereYouWantFocus").focus();
         }

One advantage would be that you wouldn't need to know how many pixels south 
of your input field you need to scroll the screen; the browser rendering 
will manage that automatically, regardless of how the user sizes text.

Paul 





More information about the Javascript mailing list