简体   繁体   English

如何在iframe中强制xml概述/漂亮打印?

[英]How to force xml-outlining / pretty printing in an iframe?

An xml -file is loaded from a different domain within an iframe in a Webkit/Chrome browser and the HTTP Content-Type is set to application/xml . xml文件从Webkit / Chrome浏览器的iframe中的不同域加载,并且HTTP Content-Type设置为application/xml
Generally xml would be colored and pretty-printed, using a built-in browser content-script. 通常,使用内置的浏览器内容脚本, xml会被着色并打印精美。 In the iframe , the same xml-file will only show the text within the tags and no colored outline, as would be expected with browser-scripts turned off. iframe ,相同的xml文件将仅显示标记内的文本,而不会显示彩色轮廓,这与关闭浏览器脚本时的情况相同。

Browser: 浏览器:
在此处输入图片说明

Iframe: iframe:
在此处输入图片说明
( different content ) 不同的内容

Response headers: 响应头:

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

Adding Access-Control-Allow-Origin:* to the response-header didn't change anything. Access-Control-Allow-Origin:*到响应头没有任何改变。

Update: HTML : 更新: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>

What is the simplest solution to fix this, without abandoning iframes and resorting to XHR requests? 在不放弃iframe和诉诸XHR请求的情况下,最简单的解决方案是什么?

Use Yahoo Pipes or YQL as a proxy formatter service. 使用Yahoo Pipes或YQL作为代理格式化程序服务。 Here are some examples: 这里有些例子:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM