Home > Javascript > window.location not working in IE 6

window.location not working in IE 6

For some unknown reason, IE 6 Java-script engine doesn’t allow me to a new URL by simply changing the window.location or window.location.href properties.

The very same thing is working fine in IE 7/8, Chrome and Fire-fox. But IE 6 is doing nothing on a call like window.location.href = url; No error is returned and location of page remains the same.

On searching for this issue, i came to following solution.

This problem is resolved by replacing the direct java-script to a custom function call like:

function SetWindowLocation(url)
{
    setTimeout(function()
     {
         window.location = url;
     }, 0);
}

Calling this function will change the location in all browsers including the funny IE 6.

Advertisements
Categories: Javascript Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: