简体   繁体   English

iFrame滚动到底部时的jQuery火灾事件

[英]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. 我有以下HTML代码srcdoc在使用srcdoc属性的iframe中包含冗长的TOS。 I was wondering how can I detect with jQuery when the iframe is scrolled to the bottom. 我想知道当iframe滚动到底部时如何使用jQuery进行检测。 (eg: the user has seen the TOS) (例如:用户已经看到了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? 没有iFrame,有什么方法可以将TOS加载到HTML中吗? Try using server side code to read the content of the external TOS page and render it in a DIV. 尝试使用服务器端代码读取外部TOS页面的内容并将其呈现在DIV中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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