-1

I need to find the alert inside the child I frame from the parent.

And inside I frame i am keeping the another web page which i don't have access on it so i cant get the alert displayed inside I Frame.

So,how to find the alert message inside I frame from Parent.

Ravi G
  • 3
  • 5
  • Possible duplicate of [Access child iFrame DOM from parent page](https://stackoverflow.com/questions/5181911/access-child-iframe-dom-from-parent-page) – CMartins Sep 09 '19 at 09:34
  • Yes, Post message i tried it worked so Iframe domain is not going to post the message now to window ,so any other way to capture the alert inside the IFrame ?@WillJenkins – Ravi G Sep 09 '19 at 09:34
  • the I Frame URL is coming from different Domain so i cant get the id of those ...will it work ?@FrozenButcher – Ravi G Sep 09 '19 at 09:37

1 Answers1

1

You can't. The contents of an iframe cannot be accessed if the parent and child are served from different domains. If they could, it would be possible to wrap any 3rd party page and capture passwords etc from it.

The only way to communicate cross-domain requires you to have control of the iframe contents. If you can add a script then you can use postMessage to send events etc in both directions.

Will Jenkins
  • 9,507
  • 1
  • 27
  • 46
  • or it is possible to postMessage from Backend to UI ? – Ravi G Sep 09 '19 at 10:13
  • 1
    @RaviG postMessage communicates between windows / tabs, not the client and the server. Using postMessage needs _both_ parties to participate. – 04FS Oct 21 '19 at 09:45