未知的Domexception:用原点“ http://subdomain.lvh.me:3000&quot”阻止了一个框架。从访问跨原始框架(http://lvh.me:3000)

发布于 2025-01-31 01:01:08 字数 789 浏览 2 评论 0原文

好吧,我正在尝试在我的子域页面上运行一个iframe或window。在我的子域页面上打开,以访问域页面以供Google登录权限。但是我遇到了交叉起源错误。

我的主要页面是: http://subdomain.lvh.me:3000

,当我单击按钮时,打开或iframe用URL打开(没有区别): http://lvh.me:3000

但是,通过这种方式,我无法访问iframe.contentwindow.document to从主页获取IFRAME内容值。这就是情况: image错误

,当我尝试通过window.postmessage发送时,这是错误:这是错误: postmessage错误

无法在'domwindow'上执行'domwindow'''''': ://subdomin.lvh.me:3001')与收件人窗口的原点不匹配('http://lvh.me:3001')。

Well, I'm trying to run an iframe or window.open in my subdomain page to access the domain page for Google Login permission purposes. But i'm getting the cross origin error.

My principal page is:
http://subdomain.lvh.me:3000

And when I click on the button, a new pages open or the iframe opens (does not make difference) with the URL:
http://lvh.me:3000

But in this way I can't access iframe.contentWindow.document to get the iframe content value from the principal page. That is the situation:
Image error

And, when I try to send by window.postMessage, this is the error:
postMessage error

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://subdomin.lvh.me:3001') does not match the recipient window's origin ('http://lvh.me:3001').

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放血 2025-02-07 01:01:08

您需要在使用poste术时设置靶标领域到另一个域

postMessage(‘hello world’, ’http://lvh.me:3000/’)

You need to set the targetOrigin field when using postMessage to another domain

postMessage(‘hello world’, ’http://lvh.me:3000/’)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文