my js files are included through header. i dont want to have some .js files included in certain pages, while that particula开发者_如何学运维r page is loading. is it is possible.??? help me please.....
<?php
if (! some_condition() ) {
?>
<script …></script>
<?php
}
?>
You could use an array of files to include.
In your main file:
$jsFiles=array('jquery.js','mylib.js','test.js');
In your header file:
foreach($jsFiles as $jsFile){
print("<script type='text/javascript' src='$jsFile'></script>");
}
Code is not tested but that should give you the idea.
What specifically is the page? Can you just re-write the header on the one page? Or, if you use a header function, just rewrite the function like:
<?php
echo "<html>";
echo "<head>";
if (use a regexp to extract the page URL ) {
echo "<script> .... </script>
}
echo "</head>";
.........
<?php
if($_SERVER['PHP_SELF'] == 'page.php'){
?>
<script></script>
<?php } ?>
精彩评论