my js files are included through header. i dont want to have some .js files included in certain pages, while that particular page is loading. is it is possible.??? help me please.....
<?php
if (! some_condition() ) {
?>
<script …></script>
<?php
}
?>
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>";
.........
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.
<?php
if($_SERVER['PHP_SELF'] == 'page.php'){
?>
<script></script>
<?php } ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.