Changing window.location in IE 6
For some crazy reason, IE 6's crazy Javascript engine doesn't want to take me to a new URL by simply changing the window.location or window.location.href properties:window.location = newUrl;
// This also doesn't work!
// window.location.href = newUrl;
But, the following code which shouldn't make a difference does work!
setTimeout(function()
{
window.location = newUrl;
}, 0);
Go figure!
Comments
Weird... I've never had a problem like that with window.location. IE never ceases to amaze, eh? What's the context? When does this get called? - Luke, Thursday, October 23, 2008 On a link whose href is just a empty Javascript function, and who has an "onclick" observer (Element.observe("click", ....)). - Patrick, Thursday, October 23, 2008 Thanks for posting this man. I had the same problem, and this bizarre solution worked for me. Sure enough, ie6 continues to amaze. - Tyler, Tuesday, February 3, 2009 thanks for the solution, i was pulling my hair out. - ricky, Thursday, February 12, 2009 thx a lot ... it works great for me - 2rock, Wednesday, March 11, 2009 Thanks a lot - nature, Sunday, March 22, 2009 You'd have to ask the developers at Microsoft as to why this is the case. IE6 is full of many wonderful surprises that require equally wonderful work-arounds. - Patrick, Monday, March 23, 2009 Thanks a lot it saved me time - Sarathc, Wednesday, April 8, 2009 Thanks for the tip! - A_Flama, Tuesday, April 28, 2009 Thanks pal, this really helped me out - Graham, Thursday, May 28, 2009 |
Post a comment |
