JS to determine whether the page within the IFRAME scroll to the bottom trigger event _javascript Tips

Source: Internet
Author: User
There is a need to determine whether the Web page in the IFRAME scroll to the bottom of the trigger event, the Internet to find a lot of information is said under the current page, simply on their own research, found a solution.

ClientHeight: The height of this element, taking up the height of the entire space

Offsetheight: Refers to the height of element content

ScrollTop: Can be understood as the length of the scroll bar can be scrolled

The following is the source code
Copy Code code as follows:

<iframe src= "~/files/3.html" id= "Iframepage" width= "825" onload= "Func" ( "></iframe>
<script type=" text/javascript ">
function func () {
var ifm = Document.getelem Entbyid ("Iframepage");
Ifm.height = window.document.body.clientheight-100;
}
<!--has compatibility issues with Chrome, FF and IE10 no problem, online said chrome access to the IFRAME in the server environment, do not know what the situation-->
Window.document.getElementById ("Iframepage"). Contentwindow.onscroll = function aaa () {
var IFM = document.getElementById ("Iframepage"). ContentWindow.document.documentElement;
if (ifm.scrolltop = = ifm.scrollheight-ifm.clientheight) {
Alert ("In the End");
}

}
</script>

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.