<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>js Obtain the SRC example of the IFRAME </title>
<body>
<a href= "Web effects: Test ();" > Get </a>
<div id= "xxx" ><iframe src= "http://www.baidu.com" height= "" width= "100%" ></iframe></div>
<script type= "Text/javascript" >
function test (box) {
var re=/s+src= "([^"]+) "/;
var Src=document.getelementbyid (box). Innerhtml.match (re);
SRC=SRC?SRC[1]: "";
alert (SRC);
}
Test ("xxx");
</script>
</body>
If you operate freely inside an IFRAME, you can't assign a value to IFRAME.SRC.
In other words, in fact, the value of the way is existing, or the first assignment of their own, the external free link is still unable to obtain
Instance Code two
<script language= "JavaScript" >
function Test () {
Tmps tutorial rc=document.all.iftest.src;
alert (TMPSRC);
}
function Gogo (IFSRC) {
DOCUMENT.ALL.IFTEST.SRC=IFSRC;
}
</script>
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" height= "100%" >
<tr>
<TD height= "258" colspan= "2" >
<div align= "center" ><iframe name= "Iftest" id= "Iftest"
border=0 frameborder=0 framespacing=0 height=400marginheight=0
Marginwidth=0 noresize Scrolling=no
Src= "http://www.aimeige.com.cn/" width=400 vspale= "0" ></iframe></div>
</td>
</tr>
<TR align= "center" >
<td>
<input type= "Submit" name= "Submit" value= "to Sina" onclick= "Gogo (' Http://www.111cn.net ')" >
</td>
<td>
<input type= "Submit" Name= "Submit2" value= "to Sohu" onclick= "Gogo (' Http://www.111cn.net ')" >
</td>
</tr>
<tr>
<TD colspan= "2" >
<div align= "center" ><a href= "javascript:;" onclick= "Test ()" > Show address </a></div>
</td>
</tr>
</table>