【发布时间】:2018-10-29 21:13:55
【问题描述】:
我正在尝试将 iFrame 加载到 Wordpress 网站中。 iFrame 应加载显示在this link 中的表格,并应用所有颜色和其他样式。
但是,当我在我的网站上插入 iFrame 时,它会加载表格的内容而不是 CSS。。 p>
这就是我尝试“强制”加载正确 CSS 的方式,因为我怀疑 Wordpress 主题覆盖了表格 CSS:
<script language="javascript" type="text/javascript">
function iFrameHeight() {
var h = 0;
if (!document.all) {
h = document.getElementById('blockrandom').contentDocument.height;
document.getElementById('blockrandom').style.height = h + 60 + 'px';
} else if (document.all) {
h = document.frames('blockrandom').document.body.scrollHeight;
document.all.blockrandom.style.height = h + 20 + 'px';
var cssLink1 = document.createElement("link");
cssLink1.href = "https://www.gscris.it/lmo/lmo-style.css";
cssLink1.rel = "stylesheet";
cssLink1.type = "text/css";
frames['iframe'].document.head.appendChild(cssLink1);
var cssLink2 = document.createElement("link");
cssLink2.href = "https://www.gscris.it/lmo/lmo-style-nc.css";
cssLink2.rel = "stylesheet";
cssLink2.type = "text/css";
frames['iframe'].document.head.appendChild(cssLink2);
}
}
</script>
<div>Campioni d'amicizia</div>
<iframe onload="iFrameHeight()" id="blockrandom" name="iframe" src="https://www.gscris.it/lmo/lmo.php?todo=&file=Piccamici201819.l98" width="100%" height="600" scrolling="no" align="top" frameborder="0">
Questa scelta non funziona correttamente in quanto il browser utilizzato non supporta gli Inline Frames </iframe>
我做错了什么? 这是我的website page,其中插入了 iframe(滚动到底部)。
【问题讨论】:
标签: javascript html css iframe