Re: why this doesn't work as an external file but does internally?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Hi guys,
>
> I have this code Javascript code:
>
> 	if (document.images) {
>
> img1on = new Image();   img1on.src = "<?php echo $base_url;
> ?>Graphics/<?php echo $img_home_on; ?>";
> img2on = new Image();   img2on.src = "<?php echo $base_url;
> ?>Graphics/<?php echo $img_programdetails_on; ?>";

<snip>

>
> Regards,
>
> Aaron
>

When you mix PHP and javascript together in an external file, the file
needs to be PHP and you should include it with PHP. I just recently went
through this. I had an external javascript file with some PHP in it. It
was originally called into the index.php page as:

<script type="text/javascript" src="includes/links.js">

But none of the PHP in the links.js worked.

So I renamed the file to links.php and called it in index.php like so:

<?php include 'includes/links.php'; ?>

And everything worked perfectly.

-- 
--Matthew Sims
--<http://killermookie.org>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux