SVG无法在Doc 10 HTML 4的IE 10中呈现 [英] SVG is not rendering in IE 10 with Doctype HTML 4

查看:158
本文介绍了SVG无法在Doc 10 HTML 4的IE 10中呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Language="C#" .. %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<body>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
   <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />
</svg> 
 </body>
</html>

/*上面的代码不起作用.没有得到任何输出. 如果替换第二行的Doctype,如下所示,它将起作用.

/*The above Code is not working. Not getting any output. if replace the second line the Doctype as below, it works.

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

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

有人可以帮助我了解主要区别是什么吗? */

Can any one help me in understanding whats the Key difference? */

推荐答案

关键区别在于

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

使浏览器使用怪癖模式. IE在怪胎模式下不支持SVG.

causes the browser to use quirks mode. IE does not support SVG in quirks mode.

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

使浏览器处于几乎标准模式.

只需添加一个系统标识符,就可以将您的doctype变成一种可以很容易在IE9中呈现SVG的文档类型:

You can turn your doctype into one that will render the SVG in IE9 very easily, just by adding a system identifier, like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

我不知道IE10是否可以正常工作,但是如果IE10遵循HTML5 doctype解析规则,即使是上面的doctype也会导致 quirks 模式,因此可能导致SVG无法运行使成为.

I don't know whether this will work IE10, but if IE10 follows the HTML5 doctype parsing rules like it should, even the above doctype will cause quirks mode, and therefore may cause SVG not to render.

在13年前的1999年,HTML 4.0被HTML 4.01替换为W3C建议,因此您应该使用的绝对最小文档类型是

HTML 4.0 was replaced as a W3C recommendation by HTML 4.01 over thirteen years ago in 1999 so the absolute minimum doctype you should use is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

将在符合HTML5的浏览器中导致几乎标准模式,就像您提到的XHTML文档类型一样.但这是供人们从HTML 3.2切换其网站的目的.

which will cause almost standards mode in HTML5 compliant browsers just like the XHTML doctype you mention does. But that was intended for people switching their sites from HTML 3.2.

更好的办法是确保您的网站以标准模式工作.您可以使用

Much better would be to ensure that your site works in standards mode. You can do that by using an HTML 4.01 strict doctype like

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

这是当前的W3C建议,但要记住的时间还很长.可以完成将浏览器置于标准模式的相同工作的最短字符串是

That's the current W3C recommendation but it's still a bit long to remember. The shortest string that will do the same job of putting browsers into standards mode is

<!DOCTYPE HTML>

这就是为什么选择它在HTML5和更高版本的文档中使用的原因.

which is why it was chosen for use in HTML5 and later documents.

这篇关于SVG无法在Doc 10 HTML 4的IE 10中呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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