Icon Patrick Gibsonpatrickgibson.com
news and such projects, etc. movies writings hyperlinks contact
search:
news and stuff

Wednesday, October 22, 2008

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:

var newUrl = "http://patrickgibson.com/";
window.location = newUrl;
// This also doesn't work!
// window.location.href = newUrl;

But, the following code which shouldn't make a difference does work!

var newUrl = "http://patrickgibson.com/";
setTimeout(function()
{
    window.location = newUrl;
}, 0);

Go figure!

Posted at 13:46
« The domready event for Prototype | Back to News and Such | Canon Canoscan on Mac OS X »

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
I searched a lot for the IE6 problem
Why IE6 is not working for window.location ?
I used onclick function for tag.
The onclick function invokes the window.location , but is working?
What is the reason behind it?
I am interested to know the reason for that.

- 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!
It's not the pretty but it works - and IE6 isn't pretty anyways! thanks!

- A_Flama, Tuesday, April 28, 2009


Thanks pal, this really helped me out

- Graham, Thursday, May 28, 2009


And what about document.location?

- Dmitry, Monday, July 6, 2009


Thanks for the solution!!!

- nexus, Thursday, July 9, 2009


I've been trying to figure that out for ages! Thanks a lot! I really should spend a little more time working on JS rather than all Perl!

- Graeme Lawton, Monday, July 13, 2009


cool, I havn't ran into this problem - yet! But im sure I will! Thanks!

Also, "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."

I wouldnt call any of IE6's problems wonderful, more like mind numbingly stupid problems that shouldn't even exist in the first place!

- tan social news pirate, Monday, July 13, 2009


thanks :) this solved a very annoying problem for me!

- Rob, Thursday, July 23, 2009


had this issue. weird but it worked. thanks..

- yasar, Wednesday, September 16, 2009


Worked! Thanks!

- Sona, Tuesday, October 13, 2009


Thank you! That was surely a frustrating experience until I came across your post!

- Sean, Thursday, November 5, 2009


I think IE6 might do some action wrapping when passing a function argument. Whereas, directly setting may not raise event to make it effect. I did have simliar experience when debugging my GUI coding using Javascript in IE6.

- scottchu.tw, Monday, December 14, 2009


Thanks for the post! It helped me. :)

- Lalit Mehta, Wednesday, January 13, 2010


It works!

thank you very much.

- munk, Monday, March 1, 2010


Post a comment

Name:

Email Address: (optional)

Website: (optional)

Comments:

Enter the number shown here:

back

Retrix Hosting