【发布时间】:2011-09-03 21:14:22
【问题描述】:
我正在尝试使用 JavaScript 设置 iframe 的 HTML 代码,在 Firefox 和 Chrome 上运行良好,但只显示链接,没有 Internet Explorer 9 的样式。
JavaScript 代码:
window.frames["iview"].document.body.innerHTML = txt;
txt 变量获取以下 HTML 代码:
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
a:link {
color: #0000C0;
background-color: #FFFFFF;
text-decoration: none;
target-new: none;
}
a:hover {
color: #0000FF;
background-color: #808000;
text-decoration: underline;
target-new: none;
}
</style>
</head>
<body>
<a href="http://www.domain.com">link....</a>
</body>
</html>
Internet Explorer 显示链接,但不显示 CSS 样式...
【问题讨论】:
-
你把上面所有的代码都放到了iframe的body部分??
-
是的,有没有办法设置头部也一样???
标签: javascript internet-explorer iframe innerhtml