title: Get url from iframe when origin is not the same
body: <p>I want to get the URL from an iframe when the user redirects by clicking links in the iframe. The source of the iframe is not the same as the web application.</p>
  
  <p>For example: </p>
  
  <pre><code>&lt;iframe src="startingUrl" class="embed-responsive-item" id="iframe" sandbox="" allowfullscreen&lt;/iframe&gt;
  </code></pre>
  
  <p>I add a load listener on the iframe to detect when the user redirects to other urls in this iframe:</p>
  
  <pre><code>const iframe = document.getElementById("iframe");
  
  iframe.addEventListener("load", (evt) =&gt; {
      const location = iframe.contentWindow.location;
  
      console.log(location); // this gives me a Location object where I can see the href property
      console.log(location.href); // this gives me a SecurityError: Permission denied to get property "href" on cross-origin object, I also tried to get a copy of the object but that doesn't work either.
  });
  </code></pre>
  
  <p>I know what causes this problem and I also know it is not possible. But I need to find a way to get the current URL of the page. If this is a no go then I want that the user who uses this web application can copy the url of the iframe and put it in an input field.</p>
  
  <p>Now they can do "View frame source" in chrome and This frame: view frame source or info in Firefox. But this is too complicated for the user. Is there a way they can see the URL in the iFrame or a way for the user to get the URL simpler.</p>
  
  <p>The site in the iFrame is not mine.</p>
  
  <p>All help is much appreciated!</p>