xpoopx
xpoopx

Reputation: 41

Automatically scrolling to anchor after submit

I have this little chatbox on my website with height of 450 pixels and overflow scroll. Now when user send a message and the page is refreshed, both the old and the new messages are shown. But when the page refreshes user needs to scroll down to see the latest message. How could I change this so that when the page refreshes the div is always automatically scrolled to the bottom?

Upvotes: 0

Views: 890

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074268

If you include a hash on the URL, and there's an element with a matching id, the browser will scroll down to it after loading the page. E.g.: http://example.com#x123456 will scroll down to <div id="x123456">...</div>.

Upvotes: 2

Related Questions