Is there any case where window.location will not work in a browser? (except js turned-off)
I'm wondering if there is any case where window.location will not work?
I was thinking maybe some older IE browsers don't let the javascript redirect t开发者_开发知识库he page due to some random security restriction?
Does anyone know if there is any browser/situation where window.location = "url" will fail?
No. It should work in all JS enabled browsers.
window.location = 'http://example.com';
How are you going to use it? If it is some odd way of using it then it might not work in IE.
If the redirect is inside an iframe then the main page will not redirect. This is expected though.
If there is an error elsewhere in your code:
window.location="http://www.google.com";
alert("error);
The missing "
in the alert statement will prevent execution of all code by the JS engine.
精彩评论