例如:
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中实际的地址
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中实际的地址
return document.getElementById(id).contentWindow || document.frames[id].window;
}
alert(getIFrameWin("rtm_ns_ifrm_220").location);
return document.getElementById(id).contentWindow || document.frames[id].window;
}function getlocation(){
alert(getIFrameWin("rtm_ns_ifrm_220").location);}
这个写在a页面想得到b页面的实际地址 就执行getlocation
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>