Reputation:
I have this piece of code on a php page, at the bottom:
window.opener.location.href="/index.html";
setTimeout("self.close();",3000);
This doesn't seem to work in IE6 (haven't tested any other IE version yet).
It works fine in FF, Safari, Opera, Chrome etc... But as usual, IE struggles.
So, what could be the problem.
The error message I get is: "'Window.opener.location' is null or not an object" Is there any walkaround for this?
If you need more input let me know. Thanks
BTW: I have tried changing the path back and forth... no help
Upvotes: 0
Views: 398
Reputation: 136
Did you try without the href?
And you should be checking for null anyway and undefined depending on your setup perhaps but no harm to have it always in there, and the opener may have been closed.
[Aside : I would also put a big question on use of IE6, it will add serious cost in terms of JS and CSS issues in most web projects, in my experience. Even (most - again, in my experience) clients who list it as a must will eventually cave in and upgrade to IE7 or later when they see how much of the costs the IE6 stipulation is accounting for.]
...
var target="/relative/path";
...
if(opener===null||opener===undefined||opener.closed){
opener=window.open(target); // our opener is gone or unavailable, go with new (or could set a warning/error here, etc)
}
else{
opener.location=target; // redirect the opener
}
...
//set timeout to close popup here
Upvotes: 1