Click to See Complete Forum and Search --> : JavaScript (?) Question


3Wheels
02-21-2001, 10:46 AM
Hi all,
I have a copy of my web site archived on both my Windows and Linux machines. When I access either of these off-line versions (no web server involved), I usually use file-open and drill down to the main index.html.

However, I use BASE HREF to set the parent directory to "C:/" on Windows and "/home/bubba" on Linux. This requires several hand edits throughout the web pages. I'd like to use some technique to determine which platform I'm on and set BASE HREF accordingly. This way, the HTML can be the same on both platforms.

For example, I tried to use the JavaScript File object to open a file (C:/testfile). If it returned true, set BASE HREF to "C:", else set it to "/home/bubba". But I couldn't get it to work.

Can this be done with JavaScript, plain HTML, or even Java?

TIA, Matt

ph34r
02-21-2001, 11:27 AM
Why not just use all relative referencing, and not have any problems with a base href?

3Wheels
02-21-2001, 04:35 PM
Thanks for the info. Relative paths worked. I didn't know I could use them throughout the site (files).

BTW, the following technique using testme.html as the entry point pops up one or the other index.html, depending on platform:
<!-- Single point of entry for two index.html's on different platforms-->
</HEAD>
</HTML>
<HTML>
<HEAD>

<SCRIPT LANGUAGE = "JavaScript">
document.open()
document.write(document.location)
if ( document.location == "file:///C|/sandbox/testme.html") {
parent.window.location.href="file:///C:/Software/Web/index.html"
} else {
parent.window.location.href="file:///home/bubba/Software/Web/index.html"
}
</SCRIPT>

</HEAD>
<BR>
</HTML>