View Full Version : removing javascript from HTML to external .js is not working

May 7th, 2003, 08:24 PM
I'm just getting into learning the full programming of JavaScript, so this is probably a pretty common question -- however, I have tried to copy the Javascript I've used in the body of my html, to an external file, and it is not working (and, yes, I have put a link in the body -- I also tried dropping a link in the head just to try it, but it isn't flying).

Any ideas as to what I'm doing wrong? I figured it would be a pretty straight forward copy and paste:o

You may view the source at:

Any of the pages that links to this require the same javascript rollover menu (god bless dynamic drive), and have it pasted in already. My hope is to remove it so that I may keep the html clean (as I have already done with my CSS).

May 7th, 2003, 09:31 PM
in oyur source of that page i see no link to an external javascript file that is possibley problem 1.


May 7th, 2003, 09:37 PM
Yes, I don't have a link -- I probably didn't write clearly, sorry.

I tried a link, and it didn't work -- so the site that I posted doesn't have the link -- it's the original file with the javascript still in it.

I'm trying to figure out how to get the javascript out and link it to make it work. Just cutting my <script> tags out and placing it in a .js file (without the script opening and closing) did not work.

May 7th, 2003, 09:41 PM
search for javascript inside javascript for how place javascript tags inside javascript files.

search also for external javascript file and there should be some info.

if oyu can't find anything, post back and i'll see what i can do.


May 7th, 2003, 09:47 PM
1. I don't want any of the javascript in the page -- so I don't want to nest any of the script into another script -- I want all of the script on that page taken out, and moved to an external file that I can link where I would like.

2. I have read through the 6 pages of posts, and the some odd archive pages -- and they all explain how to extract your javascript to an external file... which I understand. This one, however, is not working so well for me -- and won't let me just take it out and link it.

If your busy, no worries.

May 7th, 2003, 09:58 PM
Any ideas as to what I'm doing wrong?

You say you have tried to take the script out and "it didn't fly".

I cannot guess the reason why it didn't work and I cannot guess how you tried to extract the script and I cannot guess which bits you put into the external file.

I certainly don't have the time to do all the work for you (I am at work right now)

Maybe if you posted another page that shows how you attempted to extract the script people here can take a look and tell you which bit is causing problems.

May 7th, 2003, 10:24 PM
Of course, I don't expect you guys too, sorry if I implied that -- here's what I did.

I copied everything that was in my original html document in the <script opening and closing tags, and removed them to an external .js file. In my html file, I placed the link as such:

<script language="JavaScript" src="../style/submen.js" type="text/JavaScript"></script>

and that didn't work so I tried dumping it in the body:

<script language="JavaScript" src="../style/submen.js" type="text/JavaScript"></script>

but to know avail. The javascript is rather long, so I will post it in another section -- moderator - if I'm doing this wrong tell me to knock it off

May 7th, 2003, 10:25 PM
Nope -- the script is too long. I'll bug the guys at experts-exchange about it.

May 7th, 2003, 10:29 PM
right, get your page with your script and .js file on your web space post and link and people will try and help you. by placing it online in the context that you want it, people will be able to spot stuff that is wrong, there are common mistakes you know.


May 7th, 2003, 10:58 PM
I know this sounds rather ridiculous, but are you sure that your JavaScripts directory is up one level, and then down into the style directory?
Your script state "../style/<some>.js".
The "..", means that it's up one directory level.
The "." however means the current directory level.

Roy Sinclair
May 7th, 2003, 11:19 PM
You said you copied everything between the <script> and the </script> tags.

If you had the now useless but still common HTML comments (<!-- -->) around the script you should delete them, the .js file will fail to work if it has any html in it.

May 7th, 2003, 11:56 PM

CCONN was absolutely right... it was a simple up on the directory. :thumbsup:

Again, a reason I should not trust Dreamweaver MX -- I used it's basic 'insert javascript' method just to type the link to save time... in doing so, it did not put my the directory up correctly, and wrote it exactly as cconn said -- and it still did not catch it in it's debugger.:mad:

Thank you all for helping me out with this one -- I appreciate the patience and the knowledge... I think I need a nap at work now.