如何使IE 8在加载元素完成之前不向iFrame显示任何内容
How to make IE 8 not to show anything to an iFrame before onload element is finished?
我想隐藏iFrame中加载的网站元素。脚本和站点可能需要一段时间,因此要求iFrame内容只有在修改后才能显示。
我使用onload事件来执行隐藏元素的脚本。我可以访问iFrame内容(它在同一个域上,但不在同一服务器/网络上)。
function frameLoaded() {
sleep(3000); //simulating the time the script needs
var leftDiv = window.frames.testFrame.document.getElementById("leftcol");
leftDiv.style.display = "none";
}
简单的睡眠功能:
function sleep(milliSeconds){
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}
当第一次加载带有iFrame的网站时,会显示滚动条和一些样式元素,但没有内容文本:
http://img651.imageshack.us/img651/5082/beforeu.png
脚本完成后,页面将按原样显示(天青色的div将隐藏):
http://img51.imageshack.us/img51/6806/afterq.png
当脚本工作时,不应该显示任何内容。一个空的iframe或整个网站等待加载完成就足够了。
您可以在父页面加载中隐藏<iframe id="iframe" style="display: none">
,并在iframe的onload
事件中将其设置为可见:
function frameLoaded() {
sleep(3000); //simulating the time the script needs
var leftDiv = window.frames.testFrame.document.getElementById("leftcol");
leftDiv.style.display = "none";
document.getElementById("iframe").style.display = 'block';
}
BTW:这个睡眠功能应该扔掉。
相关文章:
- 在firefox和chrome中的左侧显示iframe滚动条
- 如何使用JS/jQuery在另一个网站上显示iframe中的特定内容
- 显示iframe外部的元素
- 带有iframe嵌入的Android WebView;t显示在4.2.2及以下
- 编码url并显示在iframe中
- 在引导程序弹出窗口中显示iframe
- 突出显示页面上嵌入的iframe中的单词
- 如何在不使用iframe或库的情况下创建剪切显示窗口区域
- 在html页面的iframe中显示一个警告框
- alert()和confirm()未显示在iframe的父级上
- 使用 iframe 显示网页的一部分
- 使用jquery添加的Iframe显示错误的源
- 使用iFrame显示下载对话框
- 延迟iframe显示,直到加载新的iframe
- 如何防止iframe显示外部网站
- 是否有可能不允许iframe显示文件下载弹出
- 内容在iFrame显示在Chrome,但不是在Firefox
- 禁止iframe显示页面
- 如何使IE 8在加载元素完成之前不向iFrame显示任何内容
- 当用户单击按钮时,链接应该在框内打开,Iframe显示空白