【发布时间】:2013-02-23 07:10:19
【问题描述】:
我编写了一个 javascript 函数来创建简单的 iframe 内容,它在所有浏览器 IE9、8、7 和 chrome 中都可以正常工作,但在 mozilla firefox 中无法正常工作,我的代码有什么问题?甚至在控制台中没有任何异常。
function (parent, child, cssfile, jsfilepath) {
var iframe = document.createElement('iframe');
iframe.id = ('MyID' + Math.floor((Math.random() * 1000000000000000000) + 1));
iframe.frameBorder = '0';
iframe.scrolling = 'no';
iframe.marginWidth = '0';
iframe.marginHeight = '0';
iframe.hspace = '0';
iframe.vspace = '0';
iframe.allowTransparency = "true";
parent.appendChild(iframe);
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
var inter = window.setInterval(function() {
if(iframeDoc.readyState == "complete") {
window.clearInterval(inter);
iframeDoc.body.innerHTML = child;
iframeDoc.body.style.background = "transparent";
addExternalCss(cssfile, iframeDoc);
addEmbedCss('body {margin:0px; padding:0px;}', iframeDoc);
addJs(jsfilepath, iframeDoc);
}
},100);
}
编辑
只在 firebug 中显示空白 iframe
<iframe scrolling="no" frameborder="0" id="MyId350236077714409500" marginwidth="0" marginheight="0">
<html><head></head><body></body></html>
</iframe>
【问题讨论】:
-
您是否禁用了所有插件以查看其中一个是否阻止了内容?
-
哪种插件?火狐插件?
-
是的,尝试暂时禁用所有插件并检查页面在没有它们的情况下是否正常工作。如果是这样,请一一打开它们以找出导致问题的原因。
-
对不起,我忘了更新我发现我的答案不需要禁用任何插件
标签: javascript firefox iframe