Closed danieljosephbrennan closed 5 years ago
Looking through the code trying to find a slot for the following:
On load, the parent hosting my web-app via iFrame needs to send me the userId. I receive the userId, fetch data from my backend and present the user specific data. Been racking my brains for 3 days now trying to find out how to do this using nuxt....any tips?
To listen to messages in the parent window you'll need to do
window.addEventListener('message', ...your event handler)
If you add a refs
with Vue, you can access the actual iframe element using this.$refs.friendlyIframe.iframeEl
and publish messages to the iframe using this.$refs.friendlyIframe.iframeEl.contentWindow.postMessage('message name')
Here's the HTML for the component with Vue Friendly Iframe:
<vue-friendly-iframe ref="friendlyIframe" :src="iframeSrc"></vue-friendly-iframe>
This is great. Very helpful. I need to intercept a message from the page in the iframe. I was using window.addEventListener on the iframe. Is there a better way to handle this with this component?