Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dreamweaver templates and IE conditionals / possible solutions #856

Closed
supsup opened this issue Nov 17, 2011 · 11 comments
Closed

Dreamweaver templates and IE conditionals / possible solutions #856

supsup opened this issue Nov 17, 2011 · 11 comments

Comments

@supsup
Copy link

supsup commented Nov 17, 2011

When you generate a page from a template in Dreamweaver it should insert a comment after the <html> tag like this:

the problem:

<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

Confuses Dreamweaver, it basically cannot find the html tag so it freaks out and puts it's comment before the doctype like this:

<!-- InstanceBegin template="/SomeFolderAtRoot/TemplateName.dwt" codeOutsideHTMLIsLocked="true" --><!doctype html>

which throws browsers into quirks mode.

from location:

http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/

I tried the following solution. Both appear to work, unsure which one is better or if there is another solution:

having the following in the template :

<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8 | !(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

results in the following generated pages:

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8 | !(IE)]><!--> <html class="no-js" lang="en"><!-- InstanceBegin template="/SomeFolderAtRoot/TemplateName.dwt" codeOutsideHTMLIsLocked="true" --> <!--<![endif]-->

kind of odd look but perhaps this is the best solution.

Also tried moving conditionals to body like this:

<!--[if lt IE 7]> <body class="no-js ie6 oldie"> <![endif]-->
<!--[if IE 7]>    <body class="no-js ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <body class="no-js ie8 oldie"> <![endif]-->
<!--[if gt IE 8 | !(IE)]><!--> <body class="no-js"> <!--<![endif]-->

which appears to work fine as well and has the benefit of not having a odd comment at top inside the conditionals.

Thinking about going with the conditional html version (closer to OG html5 boilerplate) but was uncertain if having the extra comment added there would cause any issues?

@paulirish
Copy link
Member

So this is basically a dreamweaver bug so I'm somewhat prone to close it as theirs. Maybe you can report it to them?

@supsup
Copy link
Author

supsup commented Nov 28, 2011

OK i will report to Adobe.

@supsup supsup closed this as completed Nov 28, 2011
@fatjester
Copy link

@supup, although this is a dreamweaver bug, this information saved me!

@maskedwallaby
Copy link

@supsup This fix also saved me! I probably would have spent hours trying different hacks, or reverted to ie-specific stylesheets. Thank you for posting these solutions!

@chrisbank
Copy link

FWIW, this is fixed in the next version of Dreamweaver. Dreamweaver will see the final html in the IECC's and put the template comment right after that. The template instance code will end up looking like:

<!--[if gt IE 8]><!-->
<html class="">
<!-- InstanceBegin template="/Templates/test.dwt" codeOutsideHTMLIsLocked="false" -->
<!--<![endif]-->

I would actually like the instance comment outside that last IECC but that was a lot more work to change in DW because a lot of places expected it right inside the html tag.

For people using Dreamweaver 5.5 and earlier, another work around is in the template page to use the directive form of downlevel-revealed.

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

You'll get the same results as above because Dreamweaver will parse those IECCs as documented by microsoft at http://msdn.microsoft.com/en-us/library/ms537512.aspx.

@paulirish
Copy link
Member

you rock @chrisbank
thanks very much :D

@iriegirl0311
Copy link

Help please. I'm trying to figure this out, and I just can't get it.

IE9 is the only one not reading my Dreamweaver html5 site (using a template). I tried above, but my understanding of the syntax isn't there yet apparently.

Does the Paul Irish comment go away?

When I paste what @supsup said, and save the template, Dreamweaver gives me an error message that says I need to add the following in the head section:

''

When I do it, it still adds the following before the <!doctype html> on all the files created using the template:

''

Do I use another editor to modify the template file and then reopen in Dreamweaver? If so, can you please cut & paste the exact code I need to tweak?

Please and thank you.

@supsup
Copy link
Author

supsup commented Jun 28, 2012

You don't put that inside the template what i have listed is a page generated from a template. or at least I think not at my work computer at the moment.

Inside the template you can add a tag to lock the content before the head (highly suggested -- or peopel will add crap before doctype and then throw stuff into quirks mode.)

set your template up like this:

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8 | !(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

<!-- TemplateInfo codeOutsideHTMLIsLocked="true" -->
<head>
....

OR

<!doctype html>
<html> 

<!-- TemplateInfo codeOutsideHTMLIsLocked="true" -->
<head>
...
</head>

<!--[if lt IE 7]> <body class="no-js ie6 oldie"> <![endif]-->
<!--[if IE 7]>    <body class="no-js ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <body class="no-js ie8 oldie"> <![endif]-->
<!--[if gt IE 8 | !(IE)]><!--> <body class="no-js"> <!--<![endif]-->
....

@iriegirl0311
Copy link

I'm still wondering if the Paul Irish line of code has to go away completely or not?

This is what I have based on @chrisbank's suggestion, but I don't know if it works for IE7 and IE9 too? I'm fumbling...

Here's what I have:

'<!doctype html>

<![if gt IE 8]><![endif]>

...

'

Thanks for responding, truly appreciated.

@nicolasmn
Copy link

Hey guys, just found a way to avoid this Dreamweaver bug.
Simply put the "detector" of the conditional comment in brackets, like this:

<!--[if (IE 8)]><html class="lt-ie9"><![endif]-->

@iimltd
Copy link

iimltd commented Jan 9, 2013

Hallelujah! Thanks nicolasmn! This worked! I already had the conditional elements on the page and didn't want to clutter my code. Simply added the parentheses around the IE version! whala! MUCH appreciated! =) Quickest forum search with an actual resolution to date! What a relief.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants