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


Post a comment

Name:

Email Address: (optional)

Website: (optional)

Comments:

Enter the number shown here:

back

Retrix Hosting