无法在'DOMWindow'上执行'postMessage':提供的目标源('http:// localhost')与收件人窗口的原点('http:// localhost:8585')不匹配。 [英] Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost') does not match the recipient window's origin ('http://localhost:8585').

查看:1522
本文介绍了无法在'DOMWindow'上执行'postMessage':提供的目标源('http:// localhost')与收件人窗口的原点('http:// localhost:8585')不匹配。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在父页面和iframe之间使用messageChanel转移数据!

我的父页面地址是:localhost:80

和我的iframe地址是:localhost:8585

但是我给出了这个错误!

无法在'DOMWindow'上执行'postMessage':提供的目标原点('http://92.62.182.23')与收件人窗口的原点不匹配('http://92.62.182.23 :8585')。



所以!我如何在两个端口之间转换?你知道吗?



messagechanel doc: messagechanel





感谢您的帮助

解决方案

targetOrigin 应该在发布收件人事件中的邮件和域时指定发布邮件的域。


只是添加他的行  顶部  两个页面(在java脚本标记内)表示父页面子(iframe页面)。 

document.domain = ' 92.62.182.23';


Hi
I want to use messageChanel for trancfer data between parent page and an iframe !
my parent page addres is : localhost:80
and my iframe addres is : localhost:8585
But I give this Error !
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://92.62.182.23') does not match the recipient window's origin ('http://92.62.182.23:8585').

So ! How i can trancfer between two port ?? did U know any way ?

messagechanel doc : messagechanel


Thanks for Help

解决方案

The targetOrigin should specify the domain to which message is posted while posting the message and domain from which it is coming in recipient event.


just add he bellow line on top of  both page (within java script tag) means in parent page and child(iframe page).

document.domain = '92.62.182.23';


这篇关于无法在'DOMWindow'上执行'postMessage':提供的目标源('http:// localhost')与收件人窗口的原点('http:// localhost:8585')不匹配。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆