Dreamweaver causing Quirks Mode in Internet Explorer

倾然丶 夕夏残阳落幕 提交于 2020-01-28 09:58:29

问题


I use Dreamweaver to develop Web sites. I use the templates feature extensively as it helps to make things easier maintaining conformance.

However, I notice that Dreamweaver adds the following code before the doctype:

<!-- InstanceBegin template="/templates/web-public-user-home.dwt" codeOutsideHTMLIsLocked="false" -->

This is throwing my IE into Quirks mode for obvious reasons (i.e. comment before the doctype). Is there a way of dealing with this?! Below is my doctype.

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

Regards,


回答1:


Ok, I figured this out.

Because of the extensive IE-compliance tweaking I'm doing, I was using conditional comments. However, I was using them on the html tag. There's nothing wrong with this in principle but Dreamweaver won't handle your live template updates properly when you do this (It will place the Dreamweaver-specific template lock code first before the doctype, thereby ensuring that your pages will throw Quirks mode in IE).

So what I did was move my conditional comment system away from the html tag, instead using them immediately after your opening body tag and immediately before your closing body tag like so:

<body>
<!--[if IE 6 ]> <div id="ie" class="ie6"> <![endif]-->
<!--[if IE 7 ]> <div id="ie" class="ie7"> <![endif]-->
<!--[if IE 8 ]> <div id="ie" class="ie8"> <![endif]-->
<!--[if gt IE 8 ]> <div id="ie"> <![endif]-->
<!--[if !IE]><div id="not-ie"> <![endif]-->

{YOUR HTML CODE}

  </div>
</body>

This way, Dreamweaver places the doctype and html tag before the template lock code, and your resulting pages will appear in standards mode on IE (all things being normal).

Cheers.




回答2:


Dreamweaver (incl. CS6) places the <!-- InstanceBegin template="... comment in front of the doctype tag only if it is unable to locate the opening <html> tag in your template! This happens when you forgot that tag altogether, but also when that tag is placed within conditional comments like this:

<!--[if IE 8]> <html class="ie8"> <![endif]-->

To avoid this you have to refrain from enclosing the <html> tag within conditional comments. When you use a normal undisguised <html> tag in your template code, Dreamweaver will automatically place the <!-- InstanceBegin template="... after that <html> tag in all files derived from that template and IE will not fall into quirks mode.



来源:https://stackoverflow.com/questions/6294301/dreamweaver-causing-quirks-mode-in-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!