繁体   English   中英

window.open postmessage or pass data to parent window cross domain

[英]window.open postmessage or pass data to parent window cross domain

我正在使用 window.open 打开一个域与父 window 不同的 url

url = "xyz.com/?"+form_data+"&first_page=1";
       newwindow=window.open(url,'name','height=350,width=800,top=250, left=600');

The orignal domain is different abc.com it is not a subdomain Now I am opening a form on the popup window and I wannt when ever I Submit the form on the popup window the the original window which is on the other domain should refresh or redirect到另一个页面我正在尝试 window.postmessage

window.opener.postMessage("message",'*');

在弹出窗口 window

 setInterval(function(){
 document.addEventListener('message', function(e) {
 alert('got (from ' + e.origin + '): ' + e.data);
 }, false);
 },1000);

但它现在可以正常工作 window.top 或 window.parent 现在也可以正常工作。 当我尝试在弹出窗口中使用 window.opener 时,我收到了跨源警告。

使用对弹出窗口的引用尝试打开父 window

newwindow=window.open(url,'name','height=350,width=800,top=250, left=600');
newwindow.postMessage('message','*')

暂无
暂无

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

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