Forum Moderators: open

Message Too Old, No Replies

including external .js files

how come it stops working

         

mylungsarempty

9:37 pm on Dec 28, 2003 (gmt 0)

10+ Year Member



i have index.php, right? and it's real long, so i cut the javascript between the HEAD tags and stuck it in a .js file, and tried linking to it like <script src="js.js"></script> and when that threw errors for whatever reason, i tried doing it by way of a PHP include... i just do not understand why this script would work perfectly fine until i include it instead of having it directly in index.php -- should it not just work exactly the same, as if it is actually part of index.php? Does anyone know anything about this?

RonPK

10:06 pm on Dec 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Including your JavaScript with PHP's include statement will not send the JavaScript to the browser. Have a look at the source code that the browser gets: there probably is no JavaScript.

Linking to the js-file with
<script type="text/javascript" src="js.js"></script>
should work just fine under most circumstances.

CloudLong

12:44 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



make sure in your "js.js" doesn't contain any <script> tag.

mylungsarempty

1:41 am on Dec 31, 2003 (gmt 0)

10+ Year Member



heh...

CloudLong

8:16 am on Dec 31, 2003 (gmt 0)

10+ Year Member



whats that means? did it works now?

mylungsarempty

10:19 am on Dec 31, 2003 (gmt 0)

10+ Year Member



yeah, i just left the <SCRIPT> tags in

i should have known better than that :(