views:

22

answers:

1

I have my index.html at the root of my web host, and my javascript file is in a directory(JavaScript) which is also at the root. How can I link my index to the js file? I did the following, but it's not working: <script type="text/javascript" src="JavaScript/filename.js"></script> in the head. It works when I do the inline javascript

A: 
<script type="text/javascript" src="JavaScript/file.js"></script>

Loads the file.js in the subdirectory "JavaScript". It'll work unless a base href is specified.

Edit: I see now that's pretty much what you had. Should work. You got full code or URL?

Alexander Sagen
<head><script type="text/javascript" src="JavaScript/ScrollingMessage.js"></script><link rel="stylesheet" type="text/css" href="/CSS/style.css" /></head><body><center><h1>The Website is under construction</h1> <form name="msgForm" action="" > <input type="text" name="scrollingMsg" size="25"/> </form></body>
It doesn't work for css either. It works only when all the files are at the root
here is my site: www.phathoang.info
So the server is responding that there's no such thing as http://www.phathoang.info/JavaScript/ScrollingMessage.js. You're sure it's in that folder and actually under the web root, not your home directory or whatever? If so, I would guess some server misconfiguration.
Alexander Sagen
It's just working now, have no idea what happened. thanks for ur concern!