我有一个像遗漏的类型错误:无法读取未定义的属性“顶”(popupWindow.top.close();)
if(typeof json.content[0].redirects != 'undefined'){
if(json.content[0].redirects != ''){
popupWindow = window.open(json.content[0].redirects, "Window2", "width=1000,height=800,scrollbars=yes,left=200");
var p = window.parent.document;
p.onclick = function(){
popupWindow.top.close();
};
}
}
一个脚本,它完美的作品在localhost
。
但在现场弹出窗口出现,但没有数据并显示错误:
'Uncaught TypeError: Cannot read property 'top' of undefined'.
为什么会出现这种情况?
预计结果关闭''top' window'? – guest271314
我不确定,但试试这个'popupWindow.offset()。top.close()' – abhishekkannojia
@ guest271314:yes.it在localhost中关闭,但是这个代码放到服务器中并不起作用 – anjana