2

I've discovered a solution to an IE problem with a conditional comment. I only need it on the home page because I've isolated there with a class on only one image. Unfortunately, the comment causes me some problems on other pages so I need to limit the comment (and script) to function ONLY on the home page... here's what my comment looks like but it's not preventing from the other pages... I'm more designer than php guy but I'm trying...

<!--[if lt IE 9]><?php if(is_home() )?> 
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>

Would certainly appreciate any help with this. Thanks much...

Jeff

1

There are likely more elegant ways to do this sort of thing, but the quickest and easiest, using your code, would be to move the PHP conditional out of the CSS conditional. e.g. change this:

<!--[if lt IE 9]><?php if(is_home() )?> 
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>

...to this:

<?php if( is_home() ) { ?> 
<!--[if lt IE 9]>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>
<?php } ?>

Also: aren't you missing the closing of the CSS conditional here?

<?php if( is_home() ) { ?> 
    <!--[if lt IE 9]>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/unitpngfix.js"></script>
    -->
<?php } ?>
|improve this answer|||||
  • Resolved! Very appreciative! ~Jeff – Jeffrey Brown Aug 30 '11 at 19:04
  • Sorry, messed up my comments, but Chip, you were right, the close also needed to be in there. Thanks again. – Jeffrey Brown Aug 30 '11 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.