Cross-platform browser interaction between page and IFRAME (same domain)

For a specialized purpose with Aweber regarding a newsletter subscription, I have a page that loads an embedded IFRAME inside, and both are in the same domain. (Many other stackoverflow posts talk about different domains, but this question only applies to the same domain.) I need a cross-platform way (including browsers that are as old as IE6 dawn) to exchange these messages.

For example, someone fills in the name and email address and clicks the checkbox, and the hidden IFRAME next to this checkbox is in the setInterval () loop, watching it. When he receives a notification, he captures the name and email address and makes a message in the form.

At first I thought that I could just reset the cookie on the parent page, and then the IFRAME child can sit at intervals, watching this cookie. But my tests show that this will not work. A cookie is created, but IFRAME does not see it. So, I tried the meta-processing technique in IFRAME, and for some reason it could not see this cookie.

The only solution I can come up with is that the parent page will accept the checkbox (we use jQuery) and make the AJAX data transfer to the server in the database. IFRAME can then check the interval on the server via AJAX to find out if the database value has changed, and respond to it if it is. But this seems like a redesigned solution, and I'm looking for a lighter alternative that works cross-platform, even in earlier browsers from the IE6 timeframe and onward.

+4
source share
1 answer

This is much simpler: in an iframe you can access the parent variable, which contains the parent window. This way you can use parent.document to find the form, read the values, etc.

+4
source

Source: https://habr.com/ru/post/1303471/


All Articles