How to send postmessage from iframe.
I have a flutter web application.
How to send postmessage from iframe click(function() { $('#contentFrame'). This is how i am simply sending a mail. Share Improve this answer Follow Add a comment | Does anyone have a working example of how to send and receive window. e. Transfer of iFrame Data to Google Analytics 4 Now that what we want to track is present in our Never used that plugin, can't really say what's wrong with it, but, alternately you can use HTML 5 postMessage. postMessage The window. Parent Window: function toFrame(type, data) { $("iframe[data-atdl iFrame: I know that the MessageEvent has source property which is the window object that send the message. postMessage(URL,sendingOrgin), but that's not how you send data to another window. This all workers perfectly but I'm unable to match Expected with Received I have an HTML file with javascript, that opens an external payment form, process the data and send a JSON response (See image). state const formData = new FormData(); formData. My code works with parent to child and vice versa. html I am trying to send data from my cookies captured on my website into an iframe. You need to send I'm trying to communicate with post messages between a parent window and an iFrame. Things tried: iframe. Why do you say that the child iframes can't communicate directly? Actually, they can. The code you have given in your sample is intended to be used in a child iframe and it is sending a message to the parent iframe. postMessage(message Send data between parent window and child iframe - PostMessage API March 15, 2022 Alternatives to Post Message API The Channel Messaging API is a really great alternative to the Post Message API with certain benefits like according to this topic Calling a parent window function from an iframe Say that iframe can send data back to parent window. In the course of experimenting with click tracking and heatmaps I needed to discern the size of the content on a page loaded within an iFrame in order to resize a canvas that I I have a website which communicates with a third party iframe. registerViewFactory( 'hello-world-html', (int viewId) => html I'm creating Cypress e2e tests, however our app is opened as a modal (iframe) on top of a parent page. So one part of the app would be a simple Firstly, send() is continuously invoked to establish connection with the child iframe in componentDidMount until a reply is recieved. The frames are in different domains (my domain, and a Google Maps iFrame). The html at the app url will have to includes a small snippet of JS listening for the auth token from the parent window. Currently i have function with timer that sends info on page load but i want to get more info. contentWindow. It looks as following: Finding a child window: In this article, I’ll provide a quick overview of window. Without the postMessage API, you can change the URL of iframe to point to a different dashboard URL, but this causes the full page to be reloaded, causes the navigation between dashboards to be slower, and takes the dashboard in I'm looking for a way to postMessage to a sibling iFrame without any javascript in the parent page. getElementById('iframe'); iframe. # Send data from an iframe to its parent window js // Called from the iframe window. but the point is, it does not affect on the iframe. I would like to refresh the parent page when the iframe refreshes after the form submission I am at the point where I can execute a function when the iframe refreshes, but I cannot get that function to affect the parent document. According to a friend to make this work we have to send html from the server (not json), with a function that will evaluate on the client and do the real postMessage. The site which I'm loading through the iFrame has a cookie How can i send a iframe in email body. For illustrative purposes, say this is the code, which works just fine: <html&g The window. I'm using iFrame. postMessage() method and how it can be used to dispatch messages between two windows or frames. – This can be child window like: iframe, new tab window. Includes tool for testing your app - iframe communicator. You are changing and passing the event to iframe variable which has no affect on the iframe internally. My current solution does not feel ok with angular at all (especially accessin I am looking at doing something similar at the moment (a portal application with sub apps in an iFrame) You can communicate between your server and client (in either direction) by using window. postMessage, but it is used specifically within an embedded iframe to communicate with its parent window. postMessage(data,receivingOrigin) . html). postMessage({ action I try to send message from an iframe loaded from my extension to my extension (background script or content script). Mail. js application by embedding the Streamlit in an iframe. Try to load a test. parent. getElementsByTagName("BODY")[0]; After that use the window. Then, inject a script with all_frames": true, where the existence of this flag AngularJS postmessage to iframe 2 Working with HTTP POST request with AngularJS 4 How to make HTTP POST call in Angular2 and print the response For example document. Like Hi with In Internet Explorer 8, events passed as a parameter may be null, that is why you need to access the event in a different manner: In window. However on start app is getting data I'm sitting on the same. stringify(yourObject) to send it via postMessage – Justin Redhart Etighe Commented Jul 30, 2018 at 23:52 I need to do the same but the domain of the inner frame is different that the parent document. Is there any way to specify that it is applicable to all subdomains. postMessage, specifically to transmit "total tokens used" information. Code used in this page window. postMessage to send data. Specify the iframe's window object: document. I have had no luck going the other direction. I just can't send anything back. You can send messages directly from the top iframe to the bottom, or you can use index I have a page with an iframe on it, and I need a button inside the frame to do a redirection to another page, if I do it the normal way the content of the iframe will be reloaded, what I need is the main window to change its url. I want to communicate with iframe using React Hooks. The implementation should be fairly simple. In the child Document when there is a submit button w I have a Window. Just send iframe ID in message with other data. getElementById('myHTMLIFrameElement'); frame. postMessage() . postMessage allows you to send messages not only across frames (regular frame or iframe) but also across domains. parent from the iframe are blocked). message – A string or object that will be sent to the receiving window. com, peter. postMessage() method safely enables cross-origin communication between Window objects; e. Next: how we send the message is Window. com on which iframe is embedded of domain iframe. A message Channel is created using the MessageChannel() constructor. MailMessage message = new System. 1. If the form is to be submitted to an iframe within the form page, then it can be easily acheived using the target attribute of the tag. getElementById("iframe"). – Mosh Feu Commented Mar 15, 2020 at 11:58 Thanks @MoshFeu. postMessage before sharing a setup you can use to collect dataLayer interactions that happen in the iframe and process them in the parent. In my case, I need to make it work for both cases so I check for opener existence: I'm developing a Google Chrome Extension that injects a script on a webpage, gather some data from the web page, call an iframe and send that data to the iframe. How I can achiever We have an iframe in a domain different from our main website. But I can't pass a message from one iframe to another. Place in that directory a . I need to pass to it my username and password, so that when the iframe is loaded, I am automatically logged in on moodle. What you can do within a child iframe is use the window. This setup ensures secure data transfer while maintaining strict control over which origins can send or receive data. This is an old question, but I hope this answer is helpful to someone. yes i tried this but i The answer about setting the URL of the IFRAME will work if you want to send/receive from the other IFRAME. postMessage() method enables cross-origin communication between a window object and an embedded iFrame and therefore provides a mechanism to circumvent this restriction. window. postMessage('Hello from JS'); In your flutter code. So I have something like Skip to main content About I want to use Window. parent. postMessage, which allows for communication between an iframe and the hosting window. React IFrame postMessage demo Explore this online React IFrame postMessage demo sandbox and experiment with it In your iframe, you have window. 2. frames["local"]. Executing iframe. But given all the preventative tips are all client-side, I'm having tr Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers I know how you can send from the iFrame to the parent, I need to send a response message after the parent receives it. There is a new feature in HTML5, window. As pointed out here, there is a perfectly fine way to determine the sender in that scenario, without giving the allow-same-origin permission: // Sandboxed iframes which lack the 'allow-same-origin' // header have "null Wait for Iframe to be loaded. And when iframe is loaded . EDIT----- I have the following. Most articles go in depth of how and why, rather than serve as a quick recap, so I'll try to do that here. The way I've my goal is to integrate a flutter widget with the help of an iframe on my main page. hash method as described in this article . html After few tries, I got positive feedback from the client. I'm working on an application in Angular 6 with a Springboot API backend. If I understand this page correctly, you instead use otherwindow. I want press button in parents iframe and send message to child iframe ,vice versa However I am trying to send a message between two files that are in the same folder in localhost, main. The difficulty I'm having is trying to get the window object for the other iFrame from the first iFrame The page would be laid out To achieve this, you can use window. You are correct, PostMessage is used to send messages between ifames. How do I send the cookie d After clicking, read the href attribute of the clicked anchor and send it to the parent window using window. addEventListener(); This post might help you to understand more. simple i want to load a form from my primary domain to my subdomain through i frame. js parent using window. postMessage() to get around cross-domain security issues when communicating between a parent and an iframe. window. My post showed interaction from parent to child and back to the parent, but didn't detail passing I am looking for a way to obtain an iframe contentWindow object and post a message to it after some action of the user. – Or a parent window – the same, partent for iframe embedded window or window opener. postMessage didn't work but top. ) main window and an iframe can exchange data using postMessages. com and site. This is my code I wrote eventually. In flutter web I have already render it using IFrameElement. on('load', function() { this. I tried many times, but still wasn't able to send it. postMessage second attribute specifies domain to which my message can be sent. Inject a content script with "all_frames": false, in which you set a flag. We create a new tag for listening to iFrame data. Simple way read ID of iframe within this iframe is set it similar whith "name" attribute and get I call window. postMessage() This method safely enables cross-origin communication. After wading through oceans of "No, cross-domain policy is a jerk" stuff, I found window. Now how to having this information check what iframe in the main document (and of course within th If you try to read the location. Then monitor the scrollTop and height attribute of the child iframe inside the msgHandler. They all work similar. When you're running JavascriptChannel(name: 'CHANNEL_NAME', ) flutter bind to your window WebView new MessageChannel with name you wrote) how to correctly postMessage into an iframe that has sandbox attribute enabled Ask Question Asked 6 years, 7 months ago Modified 6 years, 7 months ago Viewed 6k times 3 See below sample code If I if I uncomment the The <iframe> may send the "mounted" message several times in one session, and the parent window needs to respond with model each time. I can listen to messages from the webpage normally. Do note that the parent and iframe have the same domain and protocol. Using window. postMessage( some_data, page_on_A) The <iframe> is most definitely in the context of domain B, and I've confirmed that the embedded javascript in that <iframe> executes properly and calls postMessage with the A You can always send postMessage back to the iframe and let iframe handle the message. You can use proxy iframe hosted on that other domain, you send message using postMessage to that iframe, then that iframe can do POST request (on same domain) and parent on How to communicate between an iframe and the parent page From parent page -> iframe In the parent page: const iframe = document. postMessage inside iframe to communicate with the current webpage like localhost:8080 the current webpage contain an iframe with a custom DOM In my Iframe : window. Is it possible to send a postMessage "across" two (or any number of) parents, without articifially "bubbling" it up the tree? Say the instance of iFrame B wants to say "Hello" to the instance of page. postMessage API requires two components. As Cypress does not support iframes I decided to try and run app "standalone". postMessage('some message', '*'); In the iframe: I am loading an iFrame of a different domain. a. parent sends a When you say they're under the same domain, do you just mean with each other, or with the parent page as well? If they're on the same domain as the parent page, you can bypass postMessage entirely and just call functions directly in the page Hi Arjan and welcome to SO. CHANNEL_NAME. Sending Messages with postMessage() The postMessage() method accepts two parameters. postMessage("Value", "*"); window. postMessage( "stuffYouWantToSendToTheIframe", '*' ); Your parent load handler gets called after the iframe load handler. postMessage() is triggered before iframe loading is completely done. There are 3 methods: login, sign and get information. postMessage() setup in an iFrame to send a message to the host React App. Now, we have to allow the parent to receive that message. I have to postMessage() to Parent window only if iframe completely loads the data. But if windows share the same second-level domain, for instance john. – The URL of the window that the message is being sent to. And is In this article, we take a look at the window. postMessage('click', '*') In my Alright, we’ve learned how to send a message from the child iframe to the parent window using parent. onload = function { var iframeWin = document Window. The iframe. origin will be Generate iframe and communicate via post message issues 2 postMessage from an iframe opened in in new window 0 Parent window to iframe messaging not working 11 Issue communication with postMessage from parent to 0 2 I'm integrating a Streamlit app within a Next. frames["foreign"] when I would need the foreign contentWindow to postMessage to. postMessage(dataToSend, '*'); in the browser console will show that a message has been sent, though I don't think event. I iframe window needs to listen for the "message" event, process the message, and then send a postMessage back to the window of the messenger. Of course you must count that it wont get executed before next command in iframe. You need to use the message API to communicate between an iframe and its parent. postMessage() for efficient communication, using a parent window and an embedded iframe as an example. Can I get some confirmation that it is not I looked into HTML5 PostMessage, but am unsure how I would tell the iframe where the parent is (line 3 in iframe. Is there a way for the native app to listen for PostMessage events that I send up to them? I'm aware that addJavascriptInterface exists, I'm just hoping that there's a way to reuse my existing PostMessage code without writing something new. postMessage(. postMessage to send the auth token to the iframe containing the app. Let’s break down how to implement window. I'm working on a website with cross-domain iframes that are resized to the correct height using postMessage. iframe: var data = { foo: 'bar' } var event = new CustomEvent('myCustomEvent', { detail: data }) window. You can read about the API here: window. php and iframe. The main page is not written in flutter. This can be done in a The final solution would include confirmation that iframe is loaded before we use postMessage(). This app will be shown in two iframes but I want to only show one iframe at a time. I have reviewed dozens of other similar questions, but am still stuck. Setting Up the iFrame Now, let’s focus on the iframe’s content. This tag retrieves the information from postMessage and sends it to the Data Layer. – Maksim Luzik JSON. I embed the third party iframe and send a message to it via window. didn't work but top. I have been able to pass messages from the parent window to the iframe using the window. postMessage( "value", "iframe I need to load an iframe using a src attribute. On the src page, I The API works in tandem with the Post Message API to send and receive messages. I use postMessage to send events from an iframe to it's parent document. I am searc postMessage - To: Information and samples for HTML5 and related APIs Using postMessage to post messages between windows & iframes. – user583507 I want to write a message in an iframe, then reverse it by the submit button and send it to the parent window, I have the reverse function but I don't know how to use window. com (so that their common second-level domain is site. I need to call postMessage to be handled by the page opened in an iframe element using ui. My objective is to send data from the Streamlit app to the Next. However, on the initial page load, the parent window asynchronously retrieves model from an external API, which could resolve before or after the parent window receives a "mounted" message. It also previews the Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers window. I'll refer to the two webpages as the parent that has an iframe on it and the src as the page inside the iframe. Net. Since postMessage() is part of the window object, you could try using the window object of the frame, which is found under the contentWindow property of the iframe. If you want to skip the theory (it’s much of the same content as you find in the video), you can jump straight to the Google Tag Manager / Google Analytics 4 solution by clicking this link. postMessage for this job. href property of a cross-domain iframe/window, this will throw an exception since it violates the same-origin policy. html, how would I do this using I have an iframe which is pointing to a moodle site. No initial message from the main window needed! Share Follow edited Sep 8, 2017 at 9:17 display name 4,185 2 2 gold badges 31 I am working on a project where our web app needs to integrate with a 3rd party app via the postMessage protocol. That's not possible: A content script cannot access any of the page's window object (including frames). , my attempts to access window. Here is an example demonstrates how to send a simple message between a page and a child iframe: # How to use iframe, window. How To Post Message Between Html Window & iFrame/Popup Window Steps. Earlier I was having a hard time sending a postMessage from the iframe to the parent node. The created Iframe is loaded from the extension via a content script. e iFrame) and then listen the event at parent. So you could try something like: var frame = document. postMessage did work. Here is my code: parent. postMessage() (remember to call preventDefault() on the click event to prevent navigation inside iframe) How does a browser like chrome exchange data between a window and its IFrame (window being on 1 domain name and IFrame loads content from another domain name)? My question is, how the browser can TLDR; because the parent window can directly get the iframe's Window, the browser can use an offline, event-based communication protocol to I'm creating a react app that I want my users to embed on their websites. postMessage() provides a controlled mechanism to securely circumvent this re Find window to which you want send data via postMessage. postMessage() to it. The iframe's content listens for messages using window. We do An iframe is used to embed another document inside a html page. While your code is correct in that it returns the foreign window element, I'm not able to use postMessage on it. postMessage() in Section 2. POST because data received is returned sequentially (buffered) If yo Stack Overflow for Teams Where developers & technologists share private knowledge with I'm having problems using postMessage between iframe to iframe with different domains because of cross-domain issue. – user732456 The problem is postMessage() send 'null'. They got data. , between a page and a pop-up that it spawned, or I have a greasemonkey script that opens an iframe containing a form from a different sub-domain as the parent page. Using GTM's Window Loaded trigger type (easy fix, but not great) When you create a GTM trigger you will see the Window Loaded trigger type. Text; System. confirm = => { const { homeId, correctData } = this. string getemail = textbox_email. addEventListener("message I want to send a message to the parent window like this: window. So code in parent window i am creating a vue js application that is hosted in my subdomain and i want load a form from my main site using iframe. (https:// I keep forgetting how communication between a main window and an iframe works because I don't use it so often. To quote part of your question, I need to get the postMessage that is in a <script> tag in the iframe document If you mean that you need to put or inject a <script> tag which contains postMessaging, then I'm afraid it's not possible because the same-origin policy will prevent it. The only problem I'm having is identifying which iframe has which height. php When the parent receives the message it can send its message to the iframe, and be sure the iframe is ready for it. I have a form that has been called using a iframe, now when that form is submitted i want to catch a response in the main site from where the iframe was called and depending on it would enable/disa Skip to main content About . I have 2 separate Google Tag Manager accounts - one for the iframe and one for my website. html and listen for events on it. From the MDN docs: The load event fires at the end of the document loading process. var win = document. H. This leaves the postMessage sent from the child frame not handled. reverse_service. Send postMessage from the parent domain with it's origin. postMessage (message, '*'); Where `message` is a string. addEventListener Looked at this Q & A, but it doesn't solve for my issue: PostMessage with multiple functions or custom callbacks I need to use postMessage on load and then another within a click event, and the receiver for both would be on the For say i have a Site called example. postMessage method is similar to window. Share I've read up on how to avoid security issues when using window. How does this work? My question is how I get access to postMessage to send a message to the iframe and do it without re-rending it? Component: // Component (Removed majority of unrelated code) import * as React from 'react'; interface Then to In today's video I'll be showing you how to send data from an iframe up to the parent window (the page which is embedding the iframe). parent property to get a reference to the parent window, and then use the parent's frames property to get references to all child iframes (the frames property gives you an array of such references). Since this process needs to be cross-domain, postMessage was From parent page -> iframe In the parent page: const iframe = Tagged with html, javascript, iframe. it's tricky to start communication because most of the time your aren't sure what loaded first: main window or an iframe. I'm sure it's just a problem with my syntax but I am trying to send a variable to an iframe (for colorbox to use). Probably because I can only access window. postMessage, and React. postMessage() calls in angular? I found the ng-post-message module on github and ngmodules, but I look at that code and it doesn't make a whole lot of sense to me and the documentation is lacking a working example. Fortunately, I solved it because somehow window. com, any Thanks, it works for me in a similar case. I think @CBroe is correct in that the timing is correct. PostMessage used incorrectly could I wasn't able to get this working using a querySelector approach. postMessage to send the DOM object you just read in the iframed window to the window that is hosting the iframe window. Keep a copy of the port1 from the channel object returned from the Windows on subdomains: document. David Walsh has also written a good tutorial on how to do this. These don't help me do that. I'm trying to send a simple message from a child document (an iframe) back to its direct parent using the window. There's some For example, the page can communicate with an IFrame via postMessage and send events to each others' windows. to postMessage to. Parent page can post message like this. If you control both, it's much easier and this example will cover such use-case. There is a lot of additional information I need to attach to the query. Here's how I used postMessage to get the height and width of a document in an iFrame. However, I read it as you want to set a value in an existing field. postMessage to post messages to the iFrame. location. Now I implement it using vuejs and my code is <v-card> <ifra I am trying to communicate with cross-origin resources using postMessage(), but am unable to get it to work properly. If neither of those works, you could use postMessage to tell the iframes what ID to send back, or include the ID in the query string of the iframe's URL so the iframe can get it from location. postMessage(). I use, window. postMessage() method safely enables cross-origin communication between Windo Normally, scripts on different pages are allowed to access each other if and only if the pages they originate from share the same protocol, port number, and host (also known as the "same-origin policy"). net, now i want to read the content of iframe and pass some parameter to display a textual message. never just blindly act The window. com), we can make the If B has the token, you can send it to the iframe either via query param (set the iframe URL to includes also the token) or with postMessage. My simple problem is, that i can not identify the iFrame inside of it's parent This article will tell you how to use the javascript window object’s postMessage(message, targetOrigin) method to post text messages ( or javascript object’s JSON string data ) between the iframe/popup window and it’s parent window with examples. Currently, I just put all this information in a parameter like so: <ifram The parent window and iframe window are from different domains so I am running into difficulty with same origin restrictions (i. It looks as following: I want to postMessage in one iframe and send it to another iframe, independent of the parent window. Demo of a React app with an IFrame, using window. postMessage API. platformViewRegistry. to it. document Find window to which you want send data via postMessage. htaccess file containing: I hope you have tried postMessage, this is a javascript API , but there is browser limitation. I have a flutter web application. For example This script listens for postMessage events sent by the iframe and adjusts the iframe’s height accordingly. . js to pass messages between different domains. Call the window In other words, the iframe needs to pass a message to it's parent when a button is clicked. Once the action is complete within the iframe, postMessage. I'm currently working on an application where I am loading an iframe. How can I postMessage to an iframe from then. Both the parent and the iFrame sites are under my control. If that is the case, you need to do something like: 1 I have a problem. then load the test If somebody will look for solution for the same problem I can share what I have found. append How to send the height of the inner iframe to its parent iframe? I am building a web widget. getElementById('cross_domain_page'). Sending a post message from the parent PostMessage must happened from the iframe itself. Since you want to send data to the iframe, register an event listener on it: window. php, but the iframe does not listen to it, I have tried to use many target origin like this: mainpage. There is one more way (using html5 feature). addEventListener , verifies the origin, and responds to the parent window. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment window. I really need to post data to an Iframe in this case, I cannot use a $. The idea is to send a message from the top iframe and listen to it in the bottom iframe. There are many web resources (MDN, Matt West's Blog) teaching how to send a postMessage for a window, but the path is always sending a message from the parent to the iframe/popup. site. MailMe I'm trying to use the postmessage to a page opened in a webview inside a React Native App. domain By definition, two URLs with different domains have different origins. g. Set the target attribute In 2018 and modern browsers you can send a custom event from iframe to parent window. To achieve this the parent window uses window. However, I need an interface through which the main page can communicate with the widget. For configuration of the web widget, I built a generator to generate the widget code. targetOrigin – The URL of the window that the message is being sent to. One particular aspect of JavaScript that developers need t This time the iFrame does not point anymore directly to the content on SERVER 1 but to an intermediate fictive directory "content-iframe/" located on the same server (SERVER 2). postMessage, it's trivial to safely send messages from the child and have the parent receive them with the message event. search. Introduction When it comes to web development, JavaScript is an essential programming language that allows for dynamic and interactive websites. Set the allowed origin to be the 1st received origin Edit: More Info: On my server I have a whitelist domains (for example domain. Can use iframe load event and get iframe window context inside it and post to that window $('a'). For the time being I am accepting any domains on both ends (just to get it to work). I have control over both sides but the content comes from two different domains. If you want to send multiple data, you can encode in JSON: js // Called from . Within the parent document I have the following: window. But I c To send a message from Appsmith to an embedded app within an Iframe widget, use the global function postWindowMessage in your JS Object or configure a post message action for your widget in the Properties pane. PostMessage used incorrectly could If you’re seeking an answer to the question, “How can I send data from an iframe to its parent window in a web application?” you’ve come to the right place! The window. postMessage postMessage - To: Information and samples for HTML5 and related APIs Using postMessage to post messages between windows & iframes. postMessage() -- particularly the suggestions in this MDN doc. postMessage() call sends a message to the IFrame, while the window. What worked for me was the following. postMessage in your web app sends to the main document's window, not to the iframe's. Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand OverflowAI GenAI features for Teams You can use postMessage to post from child window(i. So I thought of Window postMessage and iframe in JavaScript 1. postMessage to send data to the parent window from the IFrame. postMessage, part of the HTML5 Draft The directive above triggers the iFrame to send a message to the parent window every 3 seconds. Within React app listen for In this example, the parent window sends a message to the iframe using postMessage, specifying the target origin. This iframe consists of a form where we want to track some events from outside. And if you have access to parent page code then any parent method can be called as well as any data can be passed directly from Iframe. Yes I did it. I tried to use postMessage and addEventListener in parents iframe and child iframe. When running in a New Window, postMessage needs to be sent to opener instead of parent. postMessage({type: 'gg', data: '0'}, '*'); But the parent window isn't receiving anything in the useEffect: useEffect(() => Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers How can I dynamically post data to an iframe in Jquery. The window. postMessage() method is used to forward data from parent window to iframe. contentWindow win. rtfwvzhdsanpiclmlnngvvyfwffrmvaatwbxxzroqymmnrxufwzfwfqvo