繁体   English   中英

Javascript-从弹出窗口将父级重定向到新页面

[英]Javascript - Redirect parent to new page from popup

我有一个页面,可以使用Javascript打开弹出文件选择器窗口。 用户选择文件后,父窗口将重定向到加载文档的页面。 我已经准备了很多有相同问题的帖子,但是还没有找到解决方案。 我有以下代码:

openChildWindow("FileMan2.aspx?UN=<%= Header1.UserNumber %>&FormMode=OPEN&RetObj=PRINTLETTER&PrintCase=" + OpenFlag, 550, 350);

function openChildWindow(URL, width, height) {
        if (window.showModalDialog) {
            window.showModalDialog(URL, window.self, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;center:yes;scroll:no;resizable:no;status:no;unadorned:no;edge:raised");
        } else {
            window.open(URL, "docman", "width=" + width + ", height=" + height + ", screenX=0, screenY=0, status=no, scrollbars=no,toolbar=no,menubar=no,top=200,left=200,modal=yes");
        }
    }

儿童

 var URL = window.location.protocol + "//" + window.location.host + "/CaseLetter.aspx?Case=<%= CaseNumber %>&UN=<%= Header1.UserNumber %>&Letter=" + file + "&FileName=" + file + "&COID=<%=GlobalVar.LawFirm %>&FilePath=<%= AddPath %>";
        window.opener.location.href = URL;

网址评估为“ http://example.com:80/CaseLetter.aspx?Case=35251&UN=1&Letter=asdf&FileName=asdf&COID=ar000001&FilePath=

我收到的错误是“无法获取未定义或空引用的属性'位置'。我在这里做错什么?

我会选择将对模态的引用存储在变量中的路线,然后轮询以使用模态的closed布尔值属性closed模态(当运行下面的代码片段时此方法不起作用,因为stackoverflow会阻止模态,但是您可以验证通过将其复制到您的chrome开发工具控制台中)。

 let modal = window.open("https://www.google.com?q=cats", "docman", "width=500,height=500,screenX=0, screenY=0,status=no,scrollbars=no,toolbar=no,menubar=no,top=200,left=200,modal=yes") function onClose () { alert("Modal was closed") } let intervalID = setInterval(() => { if(modal && modal.closed) { clearTimeout(intervalID) onClose() } }, 200) 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM