views:

209

answers:

1

My project is running perfectly in Firefox, google chorme and IE 8.0

But it is not working on IE 6.0 or 7.0

I realized that it is given problem at window.location I am placing my code over here to show what i am doing.

function GetEmailId()
{   
    var url="http://server.com/GetPostEmail.php";
    url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=statechangedLogin2;
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}
function statechangedLogin2()
{
    if(xmlhttp.readyState==4)
    {
     if(xmlhttp.responseText=="Login again")
     {
      window.location="http://server.com/profile.html";
     }
    }
}

So this code is working fine in other browsers except for IE 6 and 7. When i get the response from my AJAX in xmlhttp.responseText it should go over to profile.html rather in IE 6 and 7 it stays back on the original page where i was before that is qotw.html.

i think there is something wrong with the window.location, probably i need a different command here.

Also my GetXmlHttpObject looks like this.

function GetXmlHttpObject() {
  //var xmlHttp = null;
  try {
    xmlHttp = new XMLHttpRequest();
  } catch (e) {
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}

Please if anyone can help me with this problem of mine.

Regards zeeshan

Note: I again tried to decode my code and realized that in IE 6 and 7 my code never goes into statechangedLogin2(). And that is the reason my code is not working. But why is that happening as the code it working fine in other browsers even in IE8?

+1  A: 

The location property is an object, the url is the href property in that object. Use this instead:

window.location.href="http://server.com/profile.html";
Guffa