【发布时间】:2016-05-25 09:22:12
【问题描述】:
我通过给它一个 src 来创建一个带有 jquery 的 iframe,但它在 IE8 中不起作用。
$("#DB_window").append("<iframe frameborder='0' hspace='0' style='width:100%;height:100%;' src='"+urlNoQuery[0]+"' id='DB_iframeContent' name='DB_iframeContent"+Math.round(Math.random()*1000)+"' onload='db_showIframe()'> </iframe>");
它发出请求但请求被中止,所以我更改了它并尝试使用 ajax 访问它
$("#DB_window").append("<iframe frameborder='0' hspace='0' style='width:100%;height:100%;' data-src='"+urlNoQuery[0]+"' id='DB_iframeContent' name='DB_iframeContent"+Math.round(Math.random()*1000)+"' onload='db_showIframe()'> </iframe>");
并进行 ajax 调用以获取内容
var iframe = $("#DB_window").children('iframe');
$.ajax({
url: iframe.data("src"),
// dataType : "text/html",
success: function(content) {
iframe.html(content);
}
});
但在 IE8 中,它只请求 "src" url,不请求页面中的 css 和 js 引用。所以 iframe 没有正确渲染,它只带有数据,因此没有样式。我们如何在 IE 中请求 iframe。
【问题讨论】:
标签: jquery iframe internet-explorer-8 ie8-compatibility-mode