我只需要在用户关注子窗口时调用父窗口中的函数.
我在父窗口中有这个代码,
function CallParent()
{
alert(" Parent window Alert");
}
Click here to open the child window
和贝娄代码在我的孩子的窗口,
jQuery(document).ready(function(){
window.opener.CallParent();
});
This is Child window
所以..在这种情况下,我认为CallParent()将在子窗口打开后触发.但似乎没有用.
可以任何人给我任何提示,使这个脚本工作,或任何更好的方式来做到这一点.
解决方法:
用这个
window.parent.CallParent();
代替
window.opener.CallParent();
window.parent保存对当前窗口或子帧的父级的引用.
如果窗口没有父窗口,则其父属性是对自身的引用.
当窗口加载到< iframe>,< object>或< frame>时,其父窗口是嵌入窗口的元素的窗口.
标签:javascript,jquery,html5
来源: https://codeday.me/bug/20190926/1819110.html