html - iFrame 未加载 IE 8

标签 html css iframe internet-explorer-8 internet-explorer-9

<分区>

我的网站似乎可以在除 IE 8 之外的所有浏览器中运行。iFrame 可以正常加载所有内容。

这是我的 HTML 代码:

<head>
   <title> Title </title>
   <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
   <script type="text/javascript" src="respond.min.js"></script>
</head>

<body>
    <iframe src="http://instagram.com/p/cR5BORA8Ij/embed/" 
            width="300" height="400" frameborder="0" 
            scrolling="no" allowtransparency="true" id="myFrame"></iframe>      
</body>

对我可能做错的地方有什么建议吗?

最佳答案

这是一个完整的分割:

重现步骤:

创建一个在 html 元素上有 position:relative 的页面

<html style="position:relative">
    <head></head>
    <body>TEST</body>
</html>

这是一个 fiddle 中的测试页面,它就是这样做的:

http://jsfiddle.net/KyleMit/DZbt5/show/light

现在在 iFrame 中使用该页面并在 IE8 中打开

<html>
    <head></head>
    <body>
        <iframe src="http://jsfiddle.net/KyleMit/DZbt5/show/light/"></iframe>
    </body>
</html>

Here's a fiddle that should work in all browsers EXCEPT IE8

解决方案:

如前一个答案所示,您可以从原始 html 页面中删除 position:relative,但您可能无法访问该页面或无法更改它。

相反,您可以简单地将相对位置添加到 iframe 元素本身:

iframe {
    position: relative;
}

Working Demo in Fiddle - Also works in IE8

其他实例

这里也有人问了问题:

关于html - iFrame 未加载 IE 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17930418/

上一篇:c# - 将用户控件添加到用户控件时丢失样式

下一篇:html - 子菜单创造额外空间

相关文章:

css - 如何在 Google Closure Library 富文本编辑器中设置默认字体

javascript - 为什么使用 location.reload() 时我的页面没有刷新?

css - 如何让我的下拉菜单在第一个列表项之后不消失?

html - 如何垂直对齐我的图像和文本

javascript - PDF 不显示在 IE9、10 和 11 的 fancybox 2 iframe 中

html - 从 Excel Embed iFrame 中删除底部栏

javascript - 检查一个 div 是否有 child

javascript - *ngFor 循环与异步管道?

ios - iPad 设备的不同 CSS 值?

html - 链接在点击时改变字体