javascript scroll to page area [SOLVED]

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

javascript scroll to page area [SOLVED]

Post by s.dot »

I have a page loading that I give focus to a textarea. Sometimes the textarea isn't always above the "fold" of the page, in which case I want the page to scroll down a little bit to show the textarea.

Code: Select all

document.getElementById('txtForm').scrollIntoView(true);
document.getElementByTagName('body').scrollBy(0, 500000);
Both of those obviously don't work. How would I go about doing this?
Last edited by s.dot on Mon Sep 17, 2007 12:35 am, edited 1 time in total.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

document.getElementById('blah').focus()?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

feyd wrote:document.getElementById('blah').focus()?
That is putting the cursor in the textarea but doesn't scroll the page down?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Maybe if you target its container or another element scrollIntoView would work... although it appears it should work on textarea elements.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

It would help if I was uploading the correct document after saving changes. :roll:

EDIT| Just so you guys know, it's posts like these that make me feel like a moron.
/thinks about abusing mod status and deleting topic
:P
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply