I've been experiencing issues using postMessage
in Firefox and Internet Explorer, whilst Google Chrome has worked sound as a pound each time.
What I'm trying to do is use postMessage
from the iFrame to my parent with an action of closeForm
. The iFrame URL is a sub-domain of the parent, the iFrame source itself also has document.domain = document.domain
which I believe should have sorted my issues.
Currently the iFrame JavaScript is calling window.top.postMessage('closeForm', '*')
which as I've mentioned works a treat in Chrome, but in Firefox I get ReferenceError: window is undefined
so I changed window.top
to parent.postMessage
but I get get the same thing only with parent is not defined
.
The same thing doesn't work in IE9 either. Any suggestions?
It seems you're having trouble using the postmessage
. You can use the jQuery postMessage
. This is what i used in some iframe cross-domain issues and it worked. Here is the example.
window.parent
在OS X的Firefox中为我工作
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.