Click to See Complete Forum and Search --> : Dynamically selecting js source


tdm1976
09-25-2003, 04:45 AM
Firstly I apologise if this is the wrong forum for this question as I may be able to achieve something similar to what I want using some webserver (IIS) settings.
If it is perhaps somebody can point me in the right direction.

What I want to achieve is this:

I have 2 .js files on the webserver with the same name but in different directories.

e.g.

file1.js
custom/file1.js

In my HTML file I want to include custom/file1.js if it exists else I want to include file1.js. I do not ever want to include both of them.

As far as I can see there is no way of doing this. Am I correct in this or has anybody ever done anything like this.

I would not have any problems if there were only functions in these 2 files as I could just override them. However there is also code if both files that uses document.write to put out HTML. If this happens twice because both files are included then I get major problems. If I can't find a solution to this problem then we will have lots of code to rewrite which may be what we will have to do.

Any suggestions great fully appreciated.

Thanks.

Fang
09-25-2003, 05:29 AM
A server side solution would be better,
but with Javascript just check for a unique variable in custom/file1.js before loading file1.js