Javascript Not Working Within An Include

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Virtute
Forum Newbie
Posts: 1
Joined: Tue Jul 03, 2007 9:03 am

Javascript Not Working Within An Include

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I'm pretty sure it's case sensitive. Try "endif" without the capital 'I.'
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post 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]-->
Post Reply