我目前的代码是这样====== index.html ======
<iframe name="a1" src="a1.html" width="30" height="30"></iframe>
<iframe name="b1" src="b1.html" width="600" height="300"></iframe>====== a1.html ======
<script language="JavaScript">
window.parent.b1.location.href="http://www.163.com/";
</script>这是用iframe来实现的,有没有办法可以不用iframe来实现这样的功能呢
<iframe name="a1" src="a1.html" width="30" height="30"></iframe>
<iframe name="b1" src="b1.html" width="600" height="300"></iframe>====== a1.html ======
<script language="JavaScript">
window.parent.b1.location.href="http://www.163.com/";
</script>这是用iframe来实现的,有没有办法可以不用iframe来实现这样的功能呢
====== a1.html ====== window.onload=function(){
window.open("b1.html?src=163","controlB","width=100,height=200,toolbar=no,scrollbars=no,menubar=no,screenX=100,screenY=100");
}====== b1.html ====== 判断url里的src属性,如果不为空
window.onload=function(){
if(url里的src属性){
location.href="http://www."+src+".com"
}
}不知是否明白?
<button onclick='w.location.href="http://www.163.com/"'>Let b1.html Goto 163</button>
<script language="JavaScript">
setTimeout("window.parent.body1.location.href='http://www.163.com/';",10000);
setTimeout("window.parent.body1.location.href='http://www.sina.com.cn/';",20000);
setTimeout("window.parent.body1.location.href='http://www.google.com/';",30000);
</script>
<script language="javascript">
var i=0;
var TimerID;
var url=["www.baidu.com","www.126.com","www.google.com"]
window.onload=function(){
openwin();
}
function openwin(){
if(i>2){
clearTimeout(TimerID);
return;
}
var jumpurl="b1.html?src="+url[i++];
var a = window.open(jumpurl, "1", 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
TimerID=setTimeout(openwin,3000)
}
</script> <div>a1.html</div>==========b1.html==========<script language="javascript">
window.onload=function(){
var url=getUrlPara(location.href,"src");
location.href="http://"+url;
}
function getUrlPara(str,name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = str.substr(str.indexOf("\?")+1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
</script> <div>b1.html</div>
前提条件,浏览器支持弹出窗口