Question

I recently ran into an issue when preparing a web app to work in IE11. I've found a working solution but I would prefer to have a good reason why it worked rather than a guess.

My issue was an incorrect path when redirecting from the URL (http: //localhost:4724/View/Completion) to an exit page using the following javascript:

window.location = "Exit.aspx?timeout=true";

This resulted in a URL like so in IE11. Note the extra /View/:

http: //localhost:4724/View/Exit.aspx?timeout=true

In Chrome it results in the correct URL of:

http: //localhost:4724/Exit.aspx?timeout=true

I was able to correct the issue by including a forward slash when using window.location like so:

window.location = "/Exit.aspx?timeout=true";

Then it correctly routes Chrome and IE11 to the URL of:

http ://localhost:4724/Exit.aspx?timeout=true

What is IE11 interpreting differently when I include the forward slash for the window.location string?

Was it helpful?

Solution

A leading slash indicates an absolute path, i.e. a path relative to the root of the website. Without the leading slash the path is relative to the current URL.

Why it behaves differently in different browsers I can not say.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top