我想在 iframe 中显示 xml 文件。
它在 Firefox 和 IE 中工作正常,但在 chrome 中将 xml 显示为文本。
所以我想检查一下这是否是一个普遍问题。
例如:
如果我使用位于 查看 XML 食物菜单 链接http://www.w3schools.com/xml/xml_examples.asp" rel="nofollow">http://www.w3schools.com/xml/xml_examples.asp 然后我得到显示为文本的 xml文件。
如果我右键单击该链接并选择在新选项卡中打开,它将显示应有的 xml。
或者如果我打开一个新选项卡并输入网址 http://www.w3schools.com/xml/ simple.xml 它将文件显示为 xml 文件。
如果您按鼠标右键并选择“在新选项卡中打开”,它将按预期显示 xml。
我认为无论什么原因导致这个问题都会导致我面临的问题。
所以我的问题是:
- 是什么原因造成的?
- 有办法解决这个问题吗?
- 这是 Chrome 中的错误吗?
谢谢。
chrome 版本是 11.0.696.65
操作系统:windows xp,我也在 windows 7 中检查过这个
i want to show an xml file inside an iframe.
it works fine in firefox and ie but in chrome show the xml as text.
so i wanted to check if this is a general problem.
for example:
if i use the View an XML food menu link that is located in http://www.w3schools.com/xml/xml_examples.asp then i get the xml shown as a text file.
if i right click the link and chose open in new tab it will show the xml as it should.
or if i open a new tab and put the url http://www.w3schools.com/xml/simple.xml it shows the file as an xml file.
if you press the right mouse button and select "open in a new tab" it will show the xml as it should.
i think that whatever causes this problem causes the problem i am facing.
so my questions are:
- what causes this ?
- is there a way around this problem ?
- is this a bug in chrome ?
thanks.
chrome version is 11.0.696.65
OS: windows xp,i have also checked this in windows 7
发布评论
评论(3)
对我来说,这绝对是 Google Chrome 的错误。尝试右键单击该链接并选择“在新选项卡中打开链接”或“在新窗口中打开链接”以查看漂亮的打印 XML。
锚元素中有
target="_blank"
属性,这会导致问题:查看另一个网站 http://www.xmlfiles.com/examples/。没有
target="_blank"
并且链接效果很好。您可以使用“检查元素→编辑为 HTML”选项来删除该属性
target="_blank"
,之后 XML 也可以很好地打印。我终于找到了 Chromium 问题 84128(2011 年 5 月 26 日报告,版本11.0.696.71)为此。
您不需要添加任何明确的 XSLT 样式表。这里的情况根本不是这样。如果没有应用样式表,则浏览器会隐式使用其内置的默认变体。
编辑:
我下载了Google Chrome 12 beta(版本12.0.742.77 beta-m)beta-m,这里错误已解决。
(来自 http://code.google.com/p/chromium/问题/详细信息?id=434)
For me this is definitely Google Chrome bug. Try to use right-click on that link and select "Open link in new tab" or "Open link in new window" to see pretty printed XML.
There is
target="_blank"
attribute within anchor element, which causes that problem:Look at another site http://www.xmlfiles.com/examples/. There is no
target="_blank"
and links works well.You can use Inspect Element → Edit as HTML option to remove that attribute
target="_blank"
and after that XML is printed well too.Finally I found Chromium Issue 84128 (reported 26/5/2011, version 11.0.696.71) for that.
You don't need to add any explicite XSLT stylesheet. That's simply not the case here. If there is no stylesheet applied, then browser implicitly uses their built-in, default variant.
Edit:
I downloaded Google Chrome 12 beta (version 12.0.742.77 beta-m) beta-m and here this bug is solved.
(from http://code.google.com/p/chromium/issues/detail?id=434)
我认为问题在于 xml 没有引用样式表。 xml 引用样式表的其他链接第一次可以正常打开。也许添加一个最小的样式表就能解决你的问题?
I think the problem is that the xml does not reference a stylesheet. The other links where the xml does reference a stylesheet open fine the first time. Maybe adding a minimal stylesheet will fix the problem for you?
据我所知,Chrome 没有 bug。 Chrome 不会对
XML
文档应用任何样式。要解决此问题,请将样式表添加到您的
XML
文件中,如下所示它应该出现在版本 + 编码之后
这是我创建的一个
stylesheet
。As far as I know, there is no Chrome bug. Chrome just does not apply any styling to
XML
docs.To fix this, add a stylesheets to your
XML
file, like soIt should appear after the version + encoding
This is one
stylesheet
I've created.