logo

Response

« Return to the main article

You are viewing this page out of context. To see it in the context it is intended please click here.

About This Page

Reply posted by David Broscious on Thu 19 Apr 2001 in response to Opening database relative URLs in JavaScript

How about this...

You're right. My work-around would fail from the root/home page.


How about this?


*****
var lownsf = ".nsf";
var upnsf = ".NSF";


path = location.pathname.split(upnsf)[0] + '.nsf/';


if(path.length > location.pathname.length) {
path = location.pathname.split(lownsf)[0] + '.nsf/';
}
*****


If the string used to split pathname (upnsf) is not found, split[0] + ".nsf/"
will return pathname + ".nsf/". In other words, path will be longer than
pathname. The IF statement handles this by trying to split pathname with a
different string (lownsf). Use lownsf or upnsf as the first pass as your
environment's naming convention dictates.


Is is perfect. No. Somewhere, for some reason, there are files out there files
with extensions like ".nSf", ".NSf", etc.


Thanks for the word about toUpperCase and toLowerCase.


David