Click to See Complete Forum and Search --> : .js file in same directory as HTML file


Ronritz
04-07-2003, 12:56 PM
I am very new to javascript so please excuse my ignorance. If the .js file has to be in the same directory as the HTML file and the HTML file is not in the root directory, does some modification to the code need to be done to direct "src=(filename).js" to the right path??

havik
04-07-2003, 01:02 PM
If they are in the same folder, then no addition is needed.

However, if the .js file is somewhere deeper than the html file, then something like the following is needed:

"web/javas/yourjavascript.js"

But if the html is deeper than the .js file, then the following is done:

"../yourjavascript.js"

But no other code modification need take place.

Havik

Ronritz
04-07-2003, 01:08 PM
Here is my problem. When both the .js and HTML files are in the root directory of my intranet site, they work. As soon as I place both files together 1 directory deep, the javascript does not work but the HTML page does display.

havik
04-07-2003, 01:14 PM
It should work by simply stating "yourjavascript.js".

Does your javascript attempt to access images, text, html, etc... ? Changing where the javascript file is placed may change the way you reference other files.

Havik

Ronritz
04-07-2003, 01:24 PM
Havik, thanks for your help so far. I am adding the dFilter.js file to my page. I have the file in 2 places now, 1 in the same directory as the HTML page and 1 in the root. The 1 in the same directory does not work. As soon as I change the src="../dFilter.js" it works. I would like to keep everything in the same folder if I could. It is the same file that can be downloaded from this site.

havik
04-07-2003, 02:29 PM
And which site is that? There's no link at this time.

Havik

Ronritz
04-07-2003, 03:05 PM
It is an intranet site within our company