Forum Moderators: open

Message Too Old, No Replies

I Need help creating a .js page

         

Rightz

4:14 pm on May 17, 2006 (gmt 0)

10+ Year Member



I'm trying to tidy up my code and put the javascript into a .js

Am I right in assuming the only code you put on the original pages would be:
<head>
<script type="text/javascript" src="test.js"></script>
</head>

I have 2 or three scripts I want to put in the .js page. Is it better to put them in sperate pages?

Also on the .js page do I start and end with the

<script type="text/javascript"> ... </script>

tags or simply put the code into it?

Many thanks

jshanman

4:30 pm on May 17, 2006 (gmt 0)

10+ Year Member



<head>
<script type="text/javascript" src="test.js"></script>
</head>

This is the correct syntax. Just place all your javascript code into the file with no start/end (<script>) tags.

You can put code in seperate files if you want, it doesn't really matter. It depends on what is easiest for maintence.

- JS