tags:

views:

26

answers:

1

Hi,

I'm getting a weird behaviour with javascript which I fail to understand: my application's javascript relative URLs are being resolved differently, depending on where the app is hosted:
a) my computer's IIS 5.1 (Windows XP) or
b) my host provider (which I'm almost sure runs Windows Server 2003).

Behaviour 1 (the normal one?) - with the app hosted on my computer's IIS

If the browser's current location is http://localhost/appvirtualdir/Newsletter/List and I run

window.location = "../Newsletter/List" 
inside Firebug's console, the browser is redirected to http://localhost/appvirtualdir/Newsletter/List (remains on the same page).

Behaviour 2 (the weird one) - with the app hosted on the provider:

If the browser's current location is http://my.domain.com/appvirtualdir/Newsletter/List and I run exactly the same script inside Firebug's console, the browser is redirected to http://my.domain.com/appvdir/Newsletter/Newsletter/List, which obviously doesn't exist.

So, the question is: why, in the second case, is javascript not "moving up the tree"?

Thanks!

A: 

Are you sure that you are on the URL http://my.domain.com/appvirtualdir/Newsletter/List and not using http://my.domain.com/appvirtualdir/Newsletter/List/ (notice the trailing slash)?

The server might think it's a directory (you're redirected to http://my.domain.com/appvirtualdir/Newsletter/List/, one way or another, which is possible, as the trailing / is simply ignored when file List is found in /appvirtualdir/Newsletter) and in that case the browser on the client-side thinks you're in directory List.

Marcel Korpel
You're correct, I hadn't noticed that I was being redirected. Let this be a lesson to distracted programmers like myself :-) Since one server puts the trailing slash and the other one doesn't, I am now using a global javascript variable set to app root path. Thank you!
dsetton