防止使用javascript从子窗口访问父窗口
我在我的页面中显示了不同网站的链接,点击后会弹出一个新窗口 除了一个给我带来麻烦外,所有的工作都很好。比如说,当我点击链接(例如www.example.com的超链接)时,会弹出一个新窗口,当我按下该页面的HTML链接时,弹出窗口关闭,父窗口加载该网站(www.example.com) 他们的代码中有这样的东西防止使用javascript从子窗口访问父窗口,javascript,jquery,Javascript,Jquery,我在我的页面中显示了不同网站的链接,点击后会弹出一个新窗口 除了一个给我带来麻烦外,所有的工作都很好。比如说,当我点击链接(例如www.example.com的超链接)时,会弹出一个新窗口,当我按下该页面的HTML链接时,弹出窗口关闭,父窗口加载该网站(www.example.com) 他们的代码中有这样的东西 window.opener.location.href = "www.example.com"; this.window.close(); 有什么方法可以防止子窗口覆盖父窗口?我不想使
window.opener.location.href = "www.example.com";
this.window.close();
有什么方法可以防止子窗口覆盖父窗口?我不想使用“onbeforeunload”,因为我不想在页面中弹出警报
添加代码段
window.name=“parentWin”;
var=document.referer!=null&(document.referer.indexOf('upd.caqh.org')>-1);
if(window.opener!=null&操纵){
if(window.opener.opener!=null){
window.opener.opener=null;
}
window.opener.location.href=“/OAS/Default.aspx?DCS_Relogon=1”;
window.opener=null;
this.window.close();
}
请您提供一个简短的代码好吗?
据我所知,window.open()可以从目标窗口返回源(父)窗口的详细信息
在这里,您可能引用了页面的类或id,这可能导致关闭该页面 我添加了找到答案的代码段。参观
<script type="text/javascript">
window.name = "parentWin";
var manipulate = document.referrer != null && (document.referrer.indexOf('upd.caqh.org') > -1);
if (window.opener != null && manipulate) {
if (window.opener.opener != null) {
window.opener.opener = null;
}
window.opener.location.href = "/OAS/Default.aspx?DCS_Relogon=1";
window.opener = null;
this.window.close();
}
</script>
this.window.close();