I need help with the window.postMessage method. I'm trying to post a message to an iframe from the parent window.
The iframe's name and ID is myFrame, and I have tried the following code, with no avail:
document.getElemen开发者_StackOverflow中文版tById('myFrame').contentWindow.postMessage('Hello','*')
Take a step back and debug.
- What does
document.getElementById('myIframe')give you? - What does
document.getElementById('myIframe').contentWindowgive you? - Do you have a global method named
postMessagein the iframe? - Is the iframe domain the same as the initial page? It has to be.
- Does the browser throw any errors in the console?
加载中,请稍侯......
精彩评论