Page 1 of 1

Javascript Not Working Within An Include

Posted: Tue Jul 03, 2007 9:11 am
by Virtute
I don't pretend to be a pro at PHP, but I do find includes quite nifty, and I've got something strange going on in my latest project.

Basically every page on the site boils down to:

Code: Select all

<?php include('includes/top.html'); ?>

Here goes the content of the page.

<?php include('includes/bottom.html'); ?>
Everything but the content is in those two includes, including the header, navigation, footer, etc.

In top.html, all the normal stuff you'd see in a header is there - including two links to CSS files:

Code: Select all

<link type="text/css" rel="stylesheet" href="css/maincss.css" />
<!--[if IE]><link type="text/css" rel="stylesheet" href="css/ie.css" /><![endIf]-->
The ie.css file is a color fix for IE6 and 7, since I use images with a background that matches the background of the page (to avoid transparency issues), and IE uses a different rasterizing engine, so without the fix the colors don't match.

The issue is that the if statement isn't working. I googled around and the only suggestion I could find was that Javascript wasn't parsing correctly within the include, but the strange thing is that I've got a whole lot more java than that just a few lines down, for rollover images, and it all parses perfectly.

Thanks in advance for any help.

Posted: Tue Jul 03, 2007 9:18 am
by superdezign
I'm pretty sure it's case sensitive. Try "endif" without the capital 'I.'

Posted: Tue Jul 03, 2007 9:18 am
by feyd
That's not Javascript. It's called a conditional comment. You probably don't need the "IE" part, try simply swapping it out for "1" for example (without quotes.)

http://msdn2.microsoft.com/en-us/library/ms537512.aspx

Moved to Client-side.

Posted: Tue Jul 03, 2007 9:48 am
by Gente
Example from one of my sites

Code: Select all

<!--[if gt IE 5]><link rel="stylesheet" type="text/css" href="css/ie.css" media="screen"/><![endif]-->