Access iFrame contentWindow in Service Portal Client script

vinuret
Kilo Contributor

Hi there,

I am using an iframe in Service portal widget to load page from another application. I have a requirement to use window.postMessage() to post a message from the widget (client script) to the child window. From the client script I tried to access the content window using $window.frames[index].contentWindow but it does not seem to work.

Can someone please suggest me how to achieve this?

Thanks in advance,

Vinu

1 ACCEPTED SOLUTION

Oleg
Mega Sage

I'd recommend you to use $window.document.querySelector or $window.document.getElementById or $window.document.querySelectorAll to query iframe element, which content you need to access. For example, if your custom Service Portal page has only one iframe, you can use $window.document.querySelector("iframe").contentWindow to access the contentWindow. Alternatively, angular.element("iframe")[0].contentWindow should work too.

View solution in original post

5 REPLIES 5

dilgit_dinesh
Kilo Contributor

Hi, 

How to post a message from our snow page when it is being accessed by another third party tool ?