Php 获取iframe中的当前url

Php 获取iframe中的当前url,php,iframe,Php,Iframe,是否可以创建带有按钮和iframe窗口的页面,当用户单击按钮时,它会将用户带到iframe窗口的当前url?document.location=document.getElementById(“iframe\u id”).contentWindow.location假设您从同一域提供Javascript,否则您将遇到。 函数FrameUrl() { 警报('url='+document.frames['frame1'].location.href); } 如“DaveRandom”所述,这是正确

是否可以创建带有按钮和iframe窗口的页面,当用户单击按钮时,它会将用户带到iframe窗口的当前url?

document.location=document.getElementById(“iframe\u id”).contentWindow.location
假设您从同一域提供Javascript,否则您将遇到。


函数FrameUrl()
{
警报('url='+document.frames['frame1'].location.href);
}

如“DaveRandom”所述,这是正确的


top.location.href=window.location.href

top.location.href=window.location.href
daverandom,但是如果iframe是google.com,用户进入了用户中的其他站点,请清除您的问题。一些代码示例。。。你的问题和PHP之间有什么关系?我需要在goole上获得serach单词。@hd1的要点非常突出-当iframe集中在Google上时,由于跨域脚本漏洞,你将无法获得iframe的URL。浏览器根本不让你得到它。嗯,好吧,那我就不能这么做?
<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>