The Battle Cats Knowledge Base

listen to events in iframe

Cookies help us deliver our Services. …But we can’t access iframe.contentWindow.onload for an iframe from another origin, so using iframe… frames are in the same domain), you can dig down into the iframe's document and add a listener directly to that. With that, both pages send and listen event on the same object (iframe document). I want to call a method when iframe finishes loading. New comments cannot be posted and votes cannot be cast.

Not sure if that'll work since OP said the frame code cannot be changed. Assuming you have script access to the frame (i.e. Did a google search but nothing comes up. Is it possible to do that in Vue? thanks! Here's how we can use it to ask for the height and width of our iFrame document. But, it was undesirable for our use case. It provides data-reactive components with a simple and flexible API. Is it possible to do that in Vue? Just be sure you wait until the frame is loaded before you do this. see : https://www.reddit.com/r/javascript/comments/84e28m/can_a_parent_document_listen_to_an_iframe/dvouibu/. Custom load event. The site may not work properly if you don't, If you do not update your browser, we suggest you visit, Press J to jump to the feed. What same domain? It might be desirable for a few use cases to wait for that to happen. Press J to jump to the feed. contentDocument does work, but is not loaded until everything else is rendered. By using our Services or clicking I agree, you agree to our use of cookies. The starting window document and the document provided for frame.html will be different. Both the origin and remote must listen for, and send, messages. Hey there, I want to call a method when iframe finishes loading. Did a google search but nothing comes up. Our code will have two parts. The DOM emits the load event on iFrame only when all the static assets have been downloaded and all the elements in the DOM tree have fired their load event. Putting the code that adds the listener in the iframe onload, makes everything work. This works great to trigger an event if the iFrame wrapper is clicked, but trying to go deeper into an element within the iFrame … I tried @loaded @onload but not @load, works smoothly! 100% Upvoted. Returns the value of the sandbox attribute in an iframe: scrolling: Not supported in HTML5. The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it. https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage, https://www.reddit.com/r/javascript/comments/84e28m/can_a_parent_document_listen_to_an_iframe/dvouibu/.

Just use v-on with the iframes onload event like you would with any other DOM event. The iframe.onload event (on the