本文介绍了如何在使用提供的用于将xhtml作为application / xml提供给IE的用户名w3时,为IE6启用符合标准的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提供了一个技巧来向IE提供xhtml

网页作为application / xml


我使用了这个技巧,现在每一个我的xhtml网页有以下

前4个起始行:


<?xml version =" 1.0" encoding =" UTF-8"?>

<?xml-stylesheet type =" text / xsl" href =" curseIE.xsl"?>

<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN" " xhtml1-strict.dtd">

< html xmlns =" http://www.w3.org/1999/xhtml">


第二行用于告诉Internet Explorer将此页面视为

html,作为w3.org建议的workaroudn(curseIE.xsl是
$ b中的文件) $ b相同的目录)。


但是现在页面以BackCompat模式呈现。我不明白。

因为很多布局已经考虑到了CSS盒子模型,我需要IE才能在符合标准的模式下渲染它(符合标准

模式是MSDN使用的术语,我只是复制它)。正如

中所述这篇MSDN文章:


如果标准兼容模式已打开DOCTYPE是XHTML(对于我的网页来说是



我还读到有些人建议不要把<?xml ......?as第一个

行因为这会使IE关闭符合标准的模式。好吧,所以我

删除<?xml ...?>,结果?符合标准的模式仍然可以关闭,通过使用

javascript :alert(document.compatMode)进行测试;


那么是否有可能使用w3的技巧将xhtml服务器提供给IE,并且

同时使页面呈现符合标准的模式?


提前多多谢谢!

http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml
webpage to IE as application/xml

I used that trick and now every one of my xhtml webpage have following
first 4 starting lines:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="curseIE.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

The second line is used to tell Internet Explorer to treat this page as
html, as a workaroudn suggested by w3.org (curseIE.xsl is a file in the
same directory).

however now the page is rendered in BackCompat mode. I don''t understand.
Because a lot of layout is already designed with CSS box model in mind, I
need IE to render it in the Standards-compliant mode ("Standards-compliant
mode" is the terminology used by MSDN I just copy it over). As stated in
this MSDN article:
http://msdn.microsoft.com/workshop/a...ts/doctype.asp
The standard compliant mode is switched on if DOCTYPE is XHTML (which is
true for my webpages)

I also read that some people suggest not to put <?xml ...?as the first
line because that makes IE switch off Standards-compliant mode. Well, so I
removed <?xml ... ?>, result? Standards-compliant mode is still switched
off, tested by using
javascript:alert(document.compatMode);

So is it possible at all to use w3''s trick to server xhtml to IE and at
the same time make the page render in Standards-compliant mode?

Thanks a lot in advance!

推荐答案



尝试正确的Doctype:


<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"

" http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


-

Gus

Try the proper Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

--
Gus




有三种方式可以提供XHTML到IE


1.使用HTML代替! (最好的)


2. W3C XHTML 1.0规范的附录C(如Gus描述的那样,

可用选项)

- 使用XHTML 1.0 Strict

- 发送text / html内容类型标题,而不是XML内容类型

- 确保doctype声明是文档,没有任何XML prolog或XSLT样式表参考。


3.发送XML和XSLT(如你引用的页面上描述的W3C,而不是

不错的选择)

这与HTML没什么关系,你发送的是一个XML文档,并且在客户端将它变成HTML -侧。虽然它确实使XSLT

样式表变得简单,但事实上它已经开始了,但它确实很简单。

To得到3.在标准渲染模式下工作,那么你需要确保XSLT变换的输出具有适当的doctype。使用

< xsl:outputelement如下:


< xsl:output method =" html"

omit -xml-declaration =" yes"

standalone =" yes"

doctype-public =" - // W3C // DTD HTML 4.01 Strict // EN" ;

doctype-system =" http://www.w3.org/TR/html4/strict.dtd"

cdata-section-elements =" script pre"

media-type =" text / html"

/>

There are three ways to serve XHTML to IE

1. Use HTML instead ! (best)

2. Appendix C of the W3C XHTML 1.0 specification (as Gus described, a
usable choice)
- Use XHTML 1.0 Strict
- Send a text/html content-type header, not an XML content type
- Make sure the doctype declaration is the first content in the
document, without any XML prolog or XSLT stylesheet reference.

3. Send XML and XSLT (As the W3C described on the page you cited, not a
good choice)
This has little to do with HTML, you''re sending an XML document and
turning it into HTML at the client-side. The fact that it was already
XHTML to begin with doesn''t matter, although it does make the XSLT
stylesheet simple.
To get 3. to work in standards rendering mode, then you need to make
sure the output of the XSLT transform has an appropriate doctype. Use
the <xsl:outputelement like this:

<xsl:output method="html"
omit-xml-declaration = "yes"
standalone = "yes"
doctype-public = "-//W3C//DTD HTML 4.01 Strict//EN"
doctype-system = "http://www.w3.org/TR/html4/strict.dtd"
cdata-section-elements = "script pre"
media-type = "text/html"
/>




尝试正确的Doctype:


<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"

" http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


Try the proper Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



我不能。这使得我网站的所有用户都依赖他们的连接来查看我的网站。
w3.org。由于ISP的竞争(不是通过提供更好的访问来竞争,而是通过阻止其他ISP的访问来竞争)很多

的中国用户,特别是一些大学生无法访问w3 .org

相当快。现在我们遇到了台湾地震,无法为99%的用户取得这个

DTD文件。

I cannot. That makes all user of my site rely on their connectivity to
w3.org to see MY website. Due to ISP competition (not competing by
providing better access but competing by block other ISP''s access) a lot
of Chinese users especially some college students cannot access w3.org
reasonably fast. Now we got a Taiwan earthquake, impossible to fetch this
DTD file for 99% users.


这篇关于如何在使用提供的用于将xhtml作为application / xml提供给IE的用户名w3时,为IE6启用符合标准的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 17:01