By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,940 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,940 IT Pros & Developers. It's quick & easy.

auto scroll to the div down the page

P: n/a
I have a div close to the bottom of the HTML page, and it is not
displayed by default. I also have a link to toggle this div at the top
of the page. So after I click the link, the div will show up. But
because the position of div in low on the page, users have to scroll
down the page to see the div. Otherwise, it is not visible directly.
So I am wondering how can I set focus to div directly so after
clicking the link, the page will automatically scroll down to the div?

Jun 20 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jun 20, 7:06 am, "u...@yahoo.com" <u...@yahoo.comwrote:
I have a div close to the bottom of the HTML page, and it is not
displayed by default. I also have a link to toggle this div at the top
of the page. So after I click the link, the div will show up. But
because the position of div in low on the page, users have to scroll
down the page to see the div. Otherwise, it is not visible directly.
So I am wondering how can I set focus to div directly so after
clicking the link, the page will automatically scroll down to the div?
Add
<a name="div"></abefore the div and use
<a href="#div">Go to DIv</ato focus it.

Example

<a href="#div">Go to div</a>

some content. ... . . .
<a name="div"></a>
<div>
content...
</div>

-----------
OR you can use scrollIntoView method:
DIVElement.scrollIntoView()

Jun 20 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.