Search code examples
phpjqueryincludeconditional-comments

php include with conditional comments


I included some jQuery script on my site. The script doesn't work with anything lower than IE7. Now I want to do the following:

<!--[if !(lt IE 7]>
    <?php include 'script.html'; ?>
<![endif]-->

It should only load the script if the browser is "not lower than IE7". But it doesn't work.

Is there any way to solve this without using a PHP based browser recognition?


Solution

  • Yes, build the browser recognition into your jQuery/javascript. In the javascript, test for capability or object you're needing, and if it's not there, then have code to deal with it.