JavaScript link

Rexmonster

New Member
Hi guys,

I have created a file containing the JavaScript for a pop-up menu and placed a link in the head of my document like so:

<script type="text/javascript" language="javascript" src="js/menu_hide.js"></script>

The problem is it doesnt work unless i paste the actual js code into the head of every page I want to use it on.

The link to the file is correct, as it is stored in a folder called js in the root folder.

Any ideas please?

Rexmonster...
 

techmistress

New Member
Hi!

There are a couple of things to consider here.

First, is the call on the script not working at all? If that is the case, it could be that you have script tags in the js you're calling on. Since you are stating the type on your page, then the js file should just contain the script, with no type tags.

Secondly, if your script isn't working for any pages but the first, it could just be a bad link. If you have pages in folders and sub-folders, then you need to put a forward slash in front of the js, that way the site always knows to look for the folder starting with the root. Like:

rc="/js/menu_hide.js"

The other thing is to put in the full url as the link:

rc="http://www.mysite.com/js/menu_hide.js"

Check those to things, and see how it looks!
 

Rexmonster

New Member
Solved

Hi Techmistress,

Thanks for that.

It was option one, the script tags in the external file.

Appreciate your help.

Rexmonster...
 
Top