How the IFRAME up and down scroll bar defaults to the bottom of the implementation principle _ basics

Source: Internet
Author: User
problem : The IFRAME up and down scroll bar how to default in the bottom, do is the chat tool, the data is much, each refresh appears in the top and bottom scrolling by default, still need to pull down below to see the chat record, there is a way to let it appear in the bottom?
Answer: Directly in the IFRAME to write Window.scrollto (0,9999999) or set div and other containers scrolltop
Copy Code code as follows:

document.getElementById ("x"). scrolltop = document.getElementById ("x"). scrollheight
Window.scrollto (0,9999999)

This is resolved at the bottom, but with new information, the scroll bar will not automatically to the bottom, I hope like QQ Chat window, there are new content, automatic to the bottom, how should we solve it?

Then you should determine what the current generated content is, that is, the top or margin-top is how much, and then set the height of the scroll bar, this can be, each generation will call the height of the scroll bar changes, each get new data, then call Window.scrollto ( 0,9999999) This method, can solve this problem!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.