[英]How do I implement postMessage() in JavaScript?
I need help with the window.postMessage
method. 我需要有关
window.postMessage
方法的帮助。 I'm trying to post a message to an iframe from the parent window. 我正在尝试从父窗口将消息发布到iframe。
The iframe's name and ID is myFrame
, and I have tried the following code, with no avail: iframe的名称和ID为
myFrame
,并且我尝试了以下代码,但无济于事:
document.getElementById('myFrame').contentWindow.postMessage('Hello','*')
Take a step back and debug. 退后一步并进行调试。
document.getElementById('myIframe')
give you? document.getElementById('myIframe')
给您什么? document.getElementById('myIframe').contentWindow
give you? document.getElementById('myIframe').contentWindow
给您什么? postMessage
in the iframe? postMessage
的全局方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.