Runtime error in IE 6
I am getting runtime error in IE 6 for below code.
function loadFromPopup(url) {
if (top.opener){
top.opener.window.location.href = url;
window.close();
return false;
}
return true;
}
Really appreciate if any one can give some suggestions开发者_StackOverflow中文版.
top
is a global variable that refers to the top-level window containing the current frame (possibly within more framesets, each of whose containing window object can be obtained recursively using each window's parent
property). opener
refers to the window that opened the current window using window.open()
.
If your document isn't within a frame, just drop the top
and use window.opener
or just opener
. opener
is already a reference to the window you want, so no need for the window
that follows it, though I wouldn't expect it to do any harm: a window
object has a property called window
that refers to itself. Also, you should check whether the opener window has been closed before doing anything to it using its closed
property.
I'm not 100% sure but doesn't opener
refer to the window? Try:
top.opener.location.href = url;
Edit: What are you trying to close with window.close
?
Don't develop for IE6. You will spend hours and hours frustrated.
IE6 is very old. Encourage your users to update their browser.
http://ie6update.com/
精彩评论