gpt4 book ai didi

javascript - iframe 有时在 Firefox 中无法工作

转载 作者:行者123 更新时间:2023-11-28 11:04:03 25 4
gpt4 key购买 nike

我有一个带有 style="display:none" 属性的 iframe。它在 Chrome 中一直运行良好,但有时在 Firefox 中会出现问题。 Firefox 中不显示任何 iframe 页面,并且它完全是随机的。

这是我在 angularjs 中的函数,它通过单击按钮来调用。

$scope.onAddGuarantorClicked = function() {
if($("#frmGuarantor").length > 0) {
$("#frmGuarantor" ).remove();
}

$("#loadingIframe").show();

var html="<div><iframe id='frmGuarantor' src='https://someUrl' width='100%' height='100%' onload='renderDone();' frameborder='0' style='display:none'></iframe></div>";
$("#dvAddGuarantor").append(html);
$("#dvAddGuarantor").css("min-height", $("#dvSummary").height());
$("#frmGuarantor").height($("#dvSummary").height() - 60);
$("#frmGuarantor").attr("src","aDemoPage?id="+$scope.applicationId);
$("#dvSummary").hide('slow');
$("#dvAddGuarantor").show('slow');
};

window.renderDone = function(){
var d = new Date(); // for now
console.log('renderDone called outside at: H:'+ d.getHours()+' M:'+d.getMinutes()+' S:'+ d.getSeconds());

$("#frmGuarantor").show();
$("#loadingIframe").hide();
};

在控制台窗口中,我发现 iframe 无法工作时出现警告。它说:

jQuery.Deferred exception: divStyle is null computeStyleTests@...

Here是完整的警告消息。

然后我搜索了该问题并发现,this漏洞。

有什么方法可以让 iframe 与 Firefox 中的 display:none 一起使用吗?

最佳答案

有一个BUG因此,Firefox 不支持 iframe 中的 display:none。为了解决这个问题,我使用了

visbility:hidden

并显示使用的iframe

$("#frmGuarantor")[0].style.visibility='visible' 

关于javascript - iframe 有时在 Firefox 中无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51645575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com