I've seen different methods for posting data to an iframe but I can't find one where I can just send a JSON object. All the methods seem to require me to use form elements to put my data in.
相关问题
- Angular RxJS mergeMap types
- Is there a limit to how many levels you can nest i
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to toggle on Order in ReactJS
You can use the Porthole JS library. It describes itself as a "JavaScript Library for Secure Cross Domain iFrame Communication".
It uses
postMessage()
if available, but reverts to a "hidden proxy" workaround for browsers that don't.Take a look at postMessage and use JSON.stringify for your message and JSON.parse in the event handler.
To actually post to a iframe you have to do
fiddle
html
javascript