无法在交叉起源上发布消息
我有以下代码,并尝试发布消息,但在A< input>中获取阻止自动关注的。跨原生蛋白子帧中的元素。
错误。
import React from 'react'
const MyFiles = () => {
React.useEffect(() => {
let frame = document.getElementById('storage')
frame.contentWindow.postMessage({user: 'admin', password: 'blahblah'}, '*');
}, []);
return (
<React.Fragment>
<div className="pt-100 pb-70">
<div className="container">
<iframe id='storage' src='https://my.domain.com' style={{width: '100%', height: '100vh'}}/>
</div>
</div>
</React.Fragment>
)
}
export default MyFiles
到底是怎么回事?
I have the below code and trying to post a message but get a Blocked autofocusing on a <input> element in a cross-origin subframe.
error.
import React from 'react'
const MyFiles = () => {
React.useEffect(() => {
let frame = document.getElementById('storage')
frame.contentWindow.postMessage({user: 'admin', password: 'blahblah'}, '*');
}, []);
return (
<React.Fragment>
<div className="pt-100 pb-70">
<div className="container">
<iframe id='storage' src='https://my.domain.com' style={{width: '100%', height: '100vh'}}/>
</div>
</div>
</React.Fragment>
)
}
export default MyFiles
What is going on?
Is this out of date SecurityError: Blocked a frame with origin from accessing a cross-origin frame?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为发布消息没有什么关系,我的错误是在使用效率上而不是on load上这样做:
Figured the error had nothing to with posting a message, my mistake was doing it on useEffect instead of an onload: