Mobile app version of vmapp.org
Login or Join
Speyer207

: Parent.dataLayer.push when iFrame is on https I want to send information from an iFrame into the parent page using a parent.dataLayer.push, see: https://stackoverflow.com/questions/22382182/google-tag-manager-datalayer-within-iframes/

@Speyer207

Posted in: #GoogleTagManager #Iframe

I want to send information from an iFrame into the parent page using a parent.dataLayer.push, see: stackoverflow.com/questions/22382182/google-tag-manager-datalayer-within-iframes/23095522#23095522
Unfortunately I have an issue with this workaround as the iFrame page is on https and the parent on http, as a result this does not work. Does someone know how to make this work anyway?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Speyer207

1 Comments

Sorted by latest first Latest Oldest Best

 

@Vandalay111

Because the two frames are using different "schemes" (aka "protocols"), browsers will consider them to be on different " origins". This means they aren't allowed to communicate with each other using normal means (i.e. direct access to each others' objects).

The only way around this is to use some form of "cross-origin communication". If you're only targeting modern browsers (i.e. IE8+), you can use the post-message APIs:
developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme