在浏览器上呈现XHTML [英] XHTML rendering on browser

查看:133
本文介绍了在浏览器上呈现XHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我创建了一个XHTML页面,但由于某种原因它不会在我的

浏览器上呈现。它显示为代码。


有什么建议吗?谢谢。

解决方案

Bill Thoralina写道:

我创建了一个XHTML页面,但由于某种原因它没有在我的
浏览器上呈现。它显示为代码。


信息不足。浏览器是IE吗?什么是声明的内容类型?

有什么建议吗?




是的。 Give是一个网址,并告诉我们哪个浏览器(和操作系统)。


-

Brian(删除.invalid给我发电子邮件)
http://www.tsmchughs.com/


Bill Thoralina写道:


我创建了一个XHTML页面,但由于某种原因它没有渲染我的
浏览器。它显示为代码。




听起来您发送了正确的内容类型,并且您正在使用错误的

Internet Explorer。您需要发送XHTML文件而不是XML,而不是HTML

,以便90%*的用户能够看到它。


*近似值。


-

Google Blogoscoped
http://blog.outer-court.com


Bill Thoralina写道:



我创建了一个XHTML页面,但由于某种原因它没有在我的
浏览器上呈现。它显示为代码。

有什么建议吗?谢谢。



首先,您应该验证您的文档,并确保它是实际的

XHTML。虽然我怀疑这会阻止它至少尝试渲染HTML,但它始终是解决大多数问题的良好开端。
http://validator.w3.org/


否则,这可能发生在以下情况:


如果从本地文件系统加载文档:

*检查它是否没有.txt扩展名。

例如。 file.html.txt或者只是file.txt,除了IE之外,它将被视为text / plain

,因为它会尝试嗅探文件

并确定它是HTML。

*如果它有.xml扩展名,并且没有声明doctype或名称空间,那么你将看到一个文档树。 IE将始终显示一个文件

树,用于扩展名为.xml的任何内容,无论是否具有

doctype和命名空间。这些文件将被视为

text / xml或application / xml。


如果这是从服务器发送的话

*检查服务器是否正在发送正确的Content-Type标头

例如。 Content-Type:text / html或Content-Type:application / xhtml + xml,

etca?|

如果它正在发送text / plain或text / xml或者application / xml然后看到

以上的原因。 XML媒体类型也是正确的,并且

应该正确呈现,但IE会错误地将其视为纯粹的XML并显示docuement树,除非你使用Dean

Edward最近的hack允许text / xml在IE中呈现。


如果这不能帮你解决问题,请发送一下一个URI

所以我们可以看到发生了什么。


-

Lachlan Hunt
http://www.lachy.id.au/
LA ********** @ lachy.id.au.update.virus.scan ners


删除.update.virus.scanners给我发电子邮件,

没有垃圾邮件和没有病毒!!!


Hi,

I created an XHTML page, but for some reason it isn''t rendering on my
browser. It is showing up as code.

Any suggestions? Thanks.

解决方案

Bill Thoralina wrote:

I created an XHTML page, but for some reason it isn''t rendering on my
browser. It is showing up as code.
Not enough info. Is the browser IE? What is the declared content-type?
Any suggestions?



Yes. Give is a url, and tell us which browser (and os).

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/


Bill Thoralina wrote:


I created an XHTML page, but for some reason it isn''t rendering on my
browser. It is showing up as code.



Sounds like you send the correct content-type, and you are using buggy
Internet Explorer. You need to send XHTML files not as XML but as HTML
for 90%* of your users to see it.

*Approximation.

--
Google Blogoscoped
http://blog.outer-court.com


Bill Thoralina wrote:

Hi,

I created an XHTML page, but for some reason it isn''t rendering on my
browser. It is showing up as code.

Any suggestions? Thanks.


First, you should validate your document and make sure it is infact
XHTML. Although I doubt this would prevent it from at least attempting
to render the HTML, it''s always a good start to solving most problems.
http://validator.w3.org/

Otherwise, this can happen in the following situations:

If the document is being loaded from your local file system:
* Check that it doesn''t have a .txt extension.
eg. file.html.txt or just file.txt, it will be treated as "text/plain"
in everything, except IE because it will attempt to sniff the document
and determine that it''s HTML.
* If it has a .xml extension, and no doctype or namespace declared,
then you will see a document tree. IE will always show a document
tree for anything with a .xml extension, whether or not is has a
doctype and namespace. These files will be treated as either
text/xml or application/xml.

If this is being sent from a server
* Check that the server is sending the correct Content-Type header
eg. Content-Type: text/html or Content-Type: application/xhtml+xml,
etca?|
If it''s sending text/plain or text/xml or application/xml then see the
above reasons. The XML media types are also correct, and
should render correctly, however IE will incorrectly treat it as
plain XML and show you the docuement tree, unless you use Dean
Edward''s recent hack which allows text/xml to render in IE.

If this doesn''t help solve your problem, could you please send a URI
so we can see what is happening.

--
Lachlan Hunt
http://www.lachy.id.au/
la**********@lachy.id.au.update.virus.scanners

Remove .update.virus.scanners to email me,
NO SPAM and NO VIRUSES!!!


这篇关于在浏览器上呈现XHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆