How to implement an iframe upstream/downstream scroll bar at the bottom by default

Source: Internet
Author: User
The iframe scroll bar is at the bottom by default. It is used as a chat tool. When there is a large amount of data, the upstream and downstream scrolling appears at each refresh is at the top by default. You need to drop it down to see the chat record, this article will introduce, as shown in and below Problem: How does the iframe scroll bar appear below by default? It is a chat tool with a large amount of data. Each time you refresh the page, the scroll up and down appears at the top by default. You need to drop down the page to view the chat record, is there a way to make it appear below?
Answer: directly write window. scrollTo (9999999) in iframe or set scrollTop for containers such as p.

The Code is as follows:


Document. getElementById ("x"). scrollTop = document. getElementById ("x"). scrollHeight
Window. scrollTo)


This is solved at the bottom, but after there is new information, the scroll bar will not automatically go to the bottom, I want to have new content like the QQ chat window, automatically to the bottom, how can this problem be solved?

Then we should determine the position of the currently generated content, that is, its top or margin-top, and then set the height of the scroll bar, the height of the scroll bar changes every time it is generated. After the new data is obtained, the window is called again. scrollTo (9999999) can solve this problem!
Related Article

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.