2

is it possible to create page with button and iframe window, that when the user click on the button it take him to the current url of the iframe window?

hakre
  • 193,403
  • 52
  • 435
  • 836
Idan Neeman
  • 119
  • 1
  • 1
  • 8

3 Answers3

2

document.location = document.getElementById("iframe_id").contentWindow.location assuming your serving the Javascript from the same domain, else you'll run into XSS vulnerabilities.

Community
  • 1
  • 1
hd1
  • 33,938
  • 5
  • 80
  • 91
0
<html>
    <head>
        <script type="text/javascript">
            function FrameUrl()
            {
                alert('url = ' + document.frames['frame1'].location.href);
            }
        </script>
    </head>
    <body>
        <a href="#" onclick="FrameUrl();">Find the iFrame URL</a>
        <iframe name="frame1" src="http://www.facebook.com" width="100%" height="400"></iframe>
    </body>
</html>
Nirav Ranpara
  • 13,753
  • 3
  • 39
  • 54
0

This correct as mention by "DaveRandom"

top.location.href = window.location.href

Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90