views:

149

answers:

3

What is a standardized alternative to window.location.href property? I was checking on w3schools.com that it is implemented in all major browsers so there's no problem but I'm rather curious how to do that properly.

From here is the statement that the function is not standardized: https://developer.mozilla.org/en/DOM/window.location

Thanks!

+5  A: 

There is nothing wrong with setting window.location.

SLaks
+1  A: 

There's no standardized way of doing it. The most well-supported way of redirecting the browser is using the href property of the location object:

window.location.href = "http://www.google.com/";
Tim Down
+4  A: 

The window object goes back as far as the original JavaScript implementation in Netscape 2.0, and location has existed in every browser since then.

The Browser Object Model outside of the DOM has tradionally not been standardised, but that changes with HTML5, which documents the window object and its location property explicitly.

bobince