在postmessage中指定多个targetOrigin uris [英] Specifying multiple targetOrigin uris in postmessage

查看:1411
本文介绍了在postmessage中指定多个targetOrigin uris的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Window.postMessage() 有一个 targetOrigin 参数,可以设置为URI(以确保消息只到达特定的URL)。它当然也可以设置为 * (不推荐),但有没有办法指定允许的多个URI?

Window.postMessage() has a targetOrigin parameter that can be set to a URI (to ensure the message reaches only a specific url). It can also be set to * of course (not recommended), but is there a way to specify multiple URIs as allowed?

目前我只是为每个域启动了一个 postMessage()调用,但至少可以说这看起来有点hacky。

At present I'm simply firing off one postMessage() call for each domain, but this seems a bit hacky to say the least.

推荐答案

不幸的是你做不到。您应该提供*或单个指定的域。

Unfortunately you can't. You should either provide "*" or single specified domain.

这篇关于在postmessage中指定多个targetOrigin uris的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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