例如:
a.html中<iframe id="rtm_ns_ifrm_220" height="536" width="766"  scrolling="no" src="b.html"</iframe>
b,html中有<a>超链接到c.html,d.html
如果点了超链接a.html怎么获取当前iframe中实际的地址

解决方案 »

  1.   

    function getIFrameWin(id){ 
    return document.getElementById(id).contentWindow || document.frames[id].window;
    }
    alert(getIFrameWin("rtm_ns_ifrm_220").location);
      

  2.   

    function getIFrameWin(id){ 
    return document.getElementById(id).contentWindow || document.frames[id].window;
    }function getlocation(){
    alert(getIFrameWin("rtm_ns_ifrm_220").location);}
    这个写在a页面想得到b页面的实际地址 就执行getlocation
      

  3.   

    我擦qq坏了
    b.htm
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
    <head>
    <title>Untitled</title>
    <script>
    function setHref(a){  
    parent.hrefurl=a.href;

    }
    </script>
    </head><body>
    <a onclick="javascript:setHref(this);" href="http://www.baidu.com" target="_self" >百度</a>
    </body>
    </html>
    a.htm
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
    <head>
    <title>Untitled</title>


    <script>
    var hrefurl="";
    function getlocation(){

    alert(hrefurl);
    } </script>
    </head><body><iframe id="rtm_ns_ifrm_220" name="rtm_ns_ifrm_220" height="536" width="766" scrolling="no" src="b.htm"></iframe><input type="button" value="test" onclick="getlocation()"/>
    </body>
    </html>