0

I am trying to fetch url hosted inside an iframe: document.getElementById('iframe').location.contentWindow.location.href .

I am getting an error saying (DOMException: Blocked a frame with origin "https://Google.com" from accessing a cross-origin frame. at :1:31).

I read about the cross origin where we can change the location of content inside iframe but can't access it (https://javascript.info/cross-window-communication). Also when I switch from "https://binge.com" to other link then url of contentWindow must change. But since I am not able to access that how can I access the changed url or add an event listener for changing DOM events.

The viewer would going through multiple sites and I want to store url of each last visited site the user goes inside the iframe.

I am new to javascript, any leads would be helpful. Thanks in advance :)

  • You cannot - for security reasons – mplungjan May 21 '20 at 17:55
  • Thanks mplungjan. But I need save url hosted inside my iframe which gets changed when user goes through multiple sites in that inframe when there is a cross-origin issue. Is there a way we can do it? – Anjali Agrawal May 21 '20 at 18:58
  • No. You might be able to use a proxy, but without such a thing (which is not trivial) you will not be able to monitor surf behaviour – mplungjan May 21 '20 at 19:00

0 Answers0