【问题标题】:Pass document.ready() of iframe to parent container将 iframe 的 document.ready() 传递给父容器
【发布时间】:2014-08-02 16:44:16
【问题描述】:

有没有办法将 iframe 的 document.ready() 传递给父容器?

我的情况是这样的:

外部内容显示在 Shadowbox 中的 iframe 中。阴影框覆盖 (#sb-overlay) 有一个带有加载图标的背景。我现在想在 iframe 中的内容完全加载后移除加载图标。

谢谢!

【问题讨论】:

标签: jquery dom iframe shadowbox


【解决方案1】:
$('iframe#iframeid').load(function() {
    //hide the loading
});

根据this 的帖子,对于iframe,load 事件已经足够好了。无需实现document.ready

【讨论】:

  • 不幸的是,这不是这样工作的。这段代码没有任何反应。
【解决方案2】:

这是代码,它对我有用:

$('.iframelink').on('click', function(){
    setTimeout(function(){
        $('iframe').load(function(){
            $('#sb-overlay').css('background-image','none');
            console.log('loaded');
        });
    }, 1000);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-04
    • 2021-06-05
    • 1970-01-01
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    相关资源
    最近更新 更多