【发布时间】:2014-07-16 03:03:25
【问题描述】:
我在我的网站中使用 iframe 中的 Twitter 小部件。我正在设计这个 iframe 没有任何问题。 我遇到的问题是我首先看到旧的 iframe,然后我可以看到样式的变化。 有没有办法在背景发生所有 css/样式更改时隐藏 iframe,然后使其可见?
我使用这个 jquery:
$(document).ready(function(){
hideTwitterBoxElements();
});
var hideTwitterAttempts = 0;
function hideTwitterBoxElements() {
setTimeout( function() {
if ( $('[id*=twitter]').length ) {
$('[id*=twitter]').each( function(){
var ibody = $(this).contents().find( 'body' );
ibody.find(".timeline .stream").css("padding-top", "10px")
if ( ibody.find(".timeline .stream .h-feed li.tweet").length )
ibody.find(".timeline").css("background-color","transparent");
ibody.find(".customisable-border").css("border","none");
ibody.find(".timeline .stream").css("overflow","hidden");
}
});
}
hideTwitterAttempts++;
if ( hideTwitterAttempts < 3 ) {
hideTwitterBoxElements();
$("#twitter").show();
}
}, 1500);
}
当我加载页面时,iframe 会在一段时间后出现(如果可能的话,我也想减少时间)然后我可以看到例如溢出变为隐藏。
提前致谢。
【问题讨论】:
-
您能在jsbin.com 上重现您的问题吗?
标签: javascript jquery css iframe twitter