Click to See Complete Forum and Search --> : Javascript not working as an external file


Brendan Nolan
07-09-2003, 02:30 AM
I have written a javascript that consists only of a function. When I include it within the page that I want to run the script from the thing works fine. However if I link to an external file like so:

<script language="JavaScript" src="somefile.js.php"></script>

It gives me an "object expected" error. The only wierd thing about what I am doing is that the extension on the file is php because I need to use information from a database, and that shouldn't cause any problems as far as I know as I have used some really freaky extensions before.

What could I possible be doing wrong?

Brendan Nolan
07-09-2003, 02:39 AM
Okay, I have no idea what I just did! All that I did was switch back to the external file linking method, and tested it again and it now works!


I really hate it when I can't figure out what is wrong.

I hate it even more when I don't know what I did to fix it.

I hate it most when I have just posted it to this forum and then it works!

learninghtml
07-10-2003, 07:55 PM
Hi Brendan,
I've had this problem too. I'm not sure why this happens but for future reference...

Create a seperate script block for your extern file include.
(DON'T put any functions declarations etc. in this block.)

Create another script block (without the external file include) for your other "in-page-functions".

That seems to work fine. (Don't ask me why, it just does!)

So long....