gpt4 book ai didi

javascript - iframe 出现问题

转载 作者:行者123 更新时间:2023-11-28 09:34:10 27 4
gpt4 key购买 nike

我一直在互联网上进行搜索,疯狂地经历了 stackover flow 并解决了我一半的问题,当您单击链接加载页面的完整大小时,我正在尝试调整 iframe 的大小,我已经得到了它在 IE 中工作,但在 FF 中没有任何反应,只是保持相同的高度,

适用于 IE 的代码

function calcHeight() {
var the_height = 0;
//find the height of the internal page
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
the_height = document.getElementById('class').contentDocument.body.offsetHeight + 140;
}
else {
the_height = document.getElementById('class').contentWindow.document.body.scrollHeight + 18;
}
document.getElementById('class').height = the_height + "px";
}

iframe代码

    <iframe src="iframback.html" name="class" id`="class" width="100%" height="auto" scrolling="no" frameborder="0" onload="calcHeight();" allowtransparency='true'></iframe></td>

任何帮助将不胜感激,我无法弄清楚这个!这是一个指向测试页面的链接,您应该能够单击“Ohio Conceal Handgun License (CHL)”并让代码显示在其旁边,并使 IFRAME 向下展开,就像在 IE 中一样。谢谢! http://www.dualactiontactics.com/Update/7/Training.html

最佳答案

您在 iframe 中使用 id` 而不是 id,请首先更改此

<iframe src="iframback.html" name="class" id`="class" width="100%" height="auto" 
scrolling="no" frameborder="0" onload="calcHeight();" allowtransparency='true'></iframe>

id`="class"id="class"

并在js中更改语句

document.getElementById('class').height = the_height + "px";

document.getElementById('class').height = the_height;

document.getElementById('class').style.height= the_height + "px";

关于javascript - iframe 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13338427/

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