1

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
  • 184,866
  • 48
  • 414
  • 792
Idan Neeman
  • 109
  • 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
  • 32,598
  • 5
  • 75
  • 87
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
  • 15,742
  • 4
  • 41
  • 57
0

This correct as mention by "DaveRandom"

top.location.href = window.location.href

Suresh Kamrushi
  • 14,655
  • 12
  • 74
  • 87