My website provides functionality for embedding a video from my website via an iframe (similar to Youtube or any other video portals).
However, is there a way to exactly detect, which website included mine as an iframe.
Tried within my iframe embed, trying to detect parent's URL
if (window !== window.top) {
console.log(window.top.location.href);
console.log(window.parent.location.href);
}
but ended up with an error
Uncaught DOMException: Blocked a frame with origin "https://myurl.com" from accessing a cross-origin frame.
at console.log (<anonymous>)
at https://www.myurl.com/embed/1544401:20:21
Is there a workaround?
UPD. Solved by using document.referrer