gpt4 book ai didi

javascript - 如何使用 Angular 6 从 Iframe 获取数据

转载 作者:搜寻专家 更新时间:2023-10-30 21:57:33 25 4
gpt4 key购买 nike

我有一些 iframe:

<iframe src="/node_modules/collaborator-gallery/dist/index.html?id=3823&amp;auto_play=true&amp;track=true&amp;initialWidth=1290&amp;childId=pymd-aaeafe70-910d-494b-ac6b-e68d8eb2de66&amp;parentUrl=http%3A%2F%2Flocalhost%3A8080%2Fresources%2Fexecute%2F20895"
width="100%" scrolling="no" marginheight="0" frameborder="0" class="embed-responsive-item" height="480px"></iframe>

通过它我使用了画廊。我如何通过 Angular 6 中的另一个组件获取事件

最佳答案

在窗口 A 的脚本中,A 在 http://example.com:8080 上:

`var popup = window.open(...popup details...);
popup.postMessage("The user is 'bob' and the password is 'secret'", "https://secure.example.net");
popup.postMessage("hello there!", "http://example.com");`

`function receiveMessage(event) {
if (event.origin !== "http://example.com")
return;
// event.data is "hi there yourself! the secret response is: rheeeeet!"
}`
`window.addEventListener("message", receiveMessage, false);`

在调用 postMessage 后的某个时间调用

`

function receiveMessage(event) {
if (event.origin !== "http://example.com:8080")
return;
// event.data is "hello there!"
event.source.postMessage("hi there yourself! the secret response " + "is: rheeeeet!", event.origin);
}`

window.addEventListener("消息", receiveMessage, false);

关于javascript - 如何使用 Angular 6 从 Iframe 获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52170003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com