【发布时间】:2013-08-29 19:21:49
【问题描述】:
xml 文件是从 Webkit/Chrome 浏览器中 iframe 内的不同域加载的,并且 HTTP Content-Type 设置为 application/xml。
通常xml 会使用内置的浏览器内容脚本进行着色和漂亮的打印。在iframe 中,同一个 xml 文件将只显示标签内的文本,而没有彩色轮廓,这与关闭浏览器脚本的预期一样。
浏览器:
iframe:
(内容不同)
响应标头:
HTTP/1.1 200 OK
Date: Thu, 29 Aug 2013 08:52:55 GMT
Server: Apache
Vary: Cookie
Content-Length: 154
Keep-Alive: timeout=15, max=10000
Connection: Keep-Alive
Content-Type: application/xml
将Access-Control-Allow-Origin:* 添加到响应头并没有改变任何东西。
更新:HTML:
<form id="api_output" target="iframepostform" action="https://example.com/api/"
method="POST" accept-charset="utf-8">....
<button type="submit">Send</button>
</form>
<iframe class="clearfix" src="" name="iframepostform"
id="iframepostform" seamless="seamless"></iframe>
在不放弃 iframe 和诉诸 XHR 请求的情况下,最简单的解决方案是什么?
【问题讨论】:
-
iframe的url是xml文件吗?
-
@dandavis:哦,谢谢你提到这一点。请参阅修改后的帖子。
-
我知道这是一篇旧帖子,但您有解决方案吗?提前致谢
标签: javascript xml iframe colors pretty-print