方法一
如何改变iframe的src地址
<body>
<input type="button" value="改变地址" onClick="parent.displayinhere.location.href='http://www.baidu.com/'">
<iframe name="displayinhere" width=250px; height=200px; src="http://www.hao123.com">
</body>
仁则见人,智则风智
1、
<input οnclick="document.all.mxh.location.replace('http://sina.com.cn')" type=button value=change><br>
<iframe id=mxh src="http://colorweb.go.163.com"></iframe>
2、
<input οnclick="document.all.rpl.innerHTML='<iframe id=mxh src=\'http://www.sina.com\'></iframe>'" type=button value=change><br>
<span id=rpl><iframe id=mxh src="http://colorweb.go.163.com"></iframe></span>
方法二
<A href="javascript:NavGoto();" onClick="functiona();return false;">通讯录</A>
<>
<iframe name="main" src="test.html"></iframe>
</>
<script>
functiona()
{
window.frames["main"].location.href=http://www.baidu.com
}
</script>
方法三
<A id="gNav_A" href="javascript:NavGoto();" onClick="NavGoto(this);return false;">主页</A>
<iframe id="infrm" src="iframe-A.html" name="infrm" width="100%" frameborder="0" οnlοad="this.height=150"></iframe>
<script type="text/javascript">
//导航
function NavGoto(O){
document.getElementById("gNav_A").className="A";
document.getElementById("gNav_B").className="A";
var NavBtn = document.getElementById("infrm");
switch(O.id){
case "gNav_A":
NavName = "管理主页";
NavID = "gNav_A";
NavUrl = "iframe-A.html";
break;
case "gNav_B":
NavName = "日记";
NavID = "gNav_B";
NavUrl = "iframe-B.html";
break;
}
document.getElementById(NavID).className="current";
NavBtn.src = NavUrl;
return false;
}
</script>