views:

73

answers:

4

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.....

+2  A: 
<?php
    if (! some_condition() ) {
?>
<script …></script>
<?php
    }
?>
David Dorward
A: 

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>";
.........
dscher
A: 

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.

zaf
A: 

<?php
if($_SERVER['PHP_SELF'] == 'page.php'){
?>

<script ...></script>
<?php } ?>

bradenkeith