无法加载iFrame CSS

编程入门 行业动态 更新时间:2024-10-28 02:31:29
本文介绍了无法加载iFrame CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试加载iFrame 到Wordpress网站。 iFrame应加载中显示的表格这个链接,应用了所有颜色和其他样式。

I'm trying to load an iFrame into a Wordpress website. The iFrame should load the table displayed in this link, with all the colors and other styles applied.

但是,当我在我的网站上插入 iFrame 时,它会加载表格的内容,但不会加载CSS 。

However, when I insert the iFrame on my website, it will load the content of the table but not the CSS.

这就是我试图'强制'的方式加载正确的CSS,因为我怀疑Wordpress主题覆盖了表CSS:

This is how I tried to 'force' load the right CSS, as I suspect the Wordpress theme is overriding the Table 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 = "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 = "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="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>

我做错了什么? 这是我的网站页面,其中插入iframe(滚动到底部)。

What am I doing wrong? This is my website page where the iframe is inserted (scroll to the bottom).

推荐答案

首先,iframe不会采用外部css。因为他们有自己的html头部和身体标签,它是一个单独的HTML文档。你不能覆盖Iframe中的任何样式。相反,您可以尝试在所需文档中附加样式表并在iframe中使用它。

First of all Iframes will not take the external css. as they have there own html head and body tags, Its a separate html document. you cannot override any styles in Iframe. instead you can try attach your stylesheet in the required document and use it in the iframe.

更多推荐

无法加载iFrame CSS

本文发布于:2023-11-02 03:23:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551235.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   iFrame   CSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!