moving javascript to an external file

Dubb

Platinum Member
Mar 25, 2003
2,495
0
0
Yes, I know, stupid noob question. I'm just getting started in learning web design, and seem to have run into a snag.

I setup a navbar for the site I'm working on (uses mouseover buttons, etc), and noticed that since this navbar appears on every page in the site, it might be a good idea to move the javascript portion to an external file to make things a bit more tidy/efficient.

Basically:

I created a js_files directory, created a navbar.js file, snipped out the code, and pasted into navbar.js.

then, where the code used to be, I did this

which as far as I can tell is correct, but the functions don't work. Help?
 

Soccer55

Golden Member
Jul 9, 2000
1,660
4
81
Try inserting the following line somewhere between the <HEAD> and </HEAD> tags: <SCRIPT TYPE="text/javascript" SRC="./js_files/functions.js"></SCRIPT>

-Tom
 

Dubb

Platinum Member
Mar 25, 2003
2,495
0
0
ah, ok, I copied the <script type=.... stuff into the .js file as well. I'm dumb.

print design is so much easier.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Soccer55
Try inserting the following line somewhere between the <HEAD> and </HEAD> tags: <SCRIPT TYPE="text/javascript" SRC="./js_files/functions.js"></SCRIPT>

-Tom
FTW!! this example is standards compliant :)