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 :)