0

I basically need to somehow display to the user which page he is browsing to in the iframe. By displaying the URL source address of currently browsed URL of an Iframe. In my code the URL does not refresh when browsed to any other link within the Iframe.

<html><body>
<iframe id="MyIframe" name="MyIframe" src="https://hello.com" 
style="height: 90%; width:100%; border: 0px; margin: 0 0 0 0;"> 
</iframe><br>
<script type="text/javascript" language="JavaScript"> 
document.write('<input type="text" style="width:100%; " '); 
document.write(' value="' + document.getElementById('MyIframe').src+ '">'); 
</script>
</body></html>
usama
  • 1
  • 1
  • So basically..you want to make the current Ifram's src as your browser URL – Rohit Kumar Nov 05 '17 at 17:32
  • You cannot access anything from an iframe that has a URL that is not from same origin as your page. Also the document.write will work ONCE when the page is loading – mplungjan Nov 05 '17 at 17:33
  • I just want to display the active url , opened in the iframe when the users browses to a link within an iframe. Is there a way we can refresh and get the active url when the users browses off to another page of the iframe. – usama Nov 05 '17 at 17:45

0 Answers0