未捕获的类型错误:无法读取属性'top'的未定义(popupWindow.top.close();)
Uncaught TypeError: Cannot read property 'top' of undefined ( 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();
};
}
}
它在CCD_ 1上运行良好
但在实时弹出窗口中出现,但没有数据,并显示错误:
"未捕获的类型错误:无法读取未定义"的属性"top"。
为什么会发生这种情况?
嗨,你可以检查弹出窗口是否像这样触发:
if (popupWindow.length) {
popupWindow.top.close();
//...continue to close popup windows
}else{
//do something
}
相关文章:
- jQuery控制台错误:无法读取属性'top'的未定义
- Jquery scrollTop动画不工作"无法读取属性'top'无风
- 使用javascript动态计算top属性
- SharePoint Javascript - Tabs absolute top;如何插入上面的图像
- scrollTop vs getBoundingClientRect().top
- 无法仅在活动服务器上读取未定义错误的属性“top”
- 正在尝试滚动页面:未捕获类型错误:无法读取属性'top'的未定义
- Window.parent and Window.top returning null
- top.window.location在IE中不起作用
- offset()-top-XX在Webkit v Firefox/IE中给出了不同的结果
- jQuery和Javascript:offset.top()没有响应
- IE7/8未添加css属性'top'动态地作为内联样式
- jQuery position().top返回0,而不是实际值
- 未捕获的类型错误:无法读取属性'top'的未定义
- jQuery $.Deferred with window.top.postMessage()
- Visual Studio 中的 Ripple Emulator:252px 后 style.top 操作失败
- 如何获取固定元素的“原始”偏移量().top
- 有没有办法查看 window.top 是否可以访问
- 我们如何使用 JavaScript 将值从 PopUpWindow 传递到 Aspx 页面
- 未捕获的类型错误:无法读取属性'top'的未定义(popupWindow.top.close();)