简体   繁体   中英

jQuery fire event when iFrame scrolled to the bottom

I have the following HTML snip of code, with a lengthy TOS inside a iframe using the srcdoc attribute. I was wondering how can I detect with jQuery when the iframe is scrolled to the bottom. (eg: the user has seen the TOS)

<html>
    <body>
        <iframe srcdoc="HTML" class="tos"></iframe>
    </body>
</html>

I have the following code but it is not working:

$(function(){
    $('.tos').scroll(function () {
        if ($(this).scrollTop() == $(this)[0].scrollHeight - $(this).height()) {
            $('.tos-checkbox').removeAttr('disabled');
        }
    });
});

Thanks

You cannot do this because of the inherent security in the browser. Opening up this kind of "capability" would bring with it all kinds of security issues.

Is there any way you can load the TOS into the HTML without an iFrame? Try using server side code to read the content of the external TOS page and render it in a DIV.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM