iframe问题 最简单方法:打开b.htm时带参数,根据参数设定iframe src 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以这样!a.htm代码:<a href=b.htm?ifrm=1.htm>Click to open 1.htm in Iframe</a><br><a href=b.htm?ifrm=2.htm>Click to open 2.htm in Iframe</a><br><a href=b.htm?ifrm=3.htm>Click to open 3.htm in Iframe</a>b.htm代码:<iframe id=ifrmid></iframe><script>function QueryString(sName){ var sSource = String(window.document.location); var sReturn = ""; var sQUS = "?"; var sAMP = "&"; var sEQ = "="; var iPos; iPos = sSource.indexOf(sQUS); var strQuery = sSource.substr(iPos, sSource.length - iPos); var strLCQuery = strQuery.toLowerCase(); var strLCName = sName.toLowerCase(); iPos = strLCQuery.indexOf(sQUS + strLCName + sEQ); if (iPos == -1) {iPos = strLCQuery.indexOf(sAMP + strLCName + sEQ);if (iPos == -1) return "";} sReturn = strQuery.substr(iPos + sName.length + 2,strQuery.length-(iPos + sName.length + 2)); var iPosAMP = sReturn.indexOf(sAMP); if (iPosAMP == -1) return sReturn; else {sReturn = sReturn.substr(0, iPosAMP);}return sReturn;}ifrmid.location=QueryString('ifrm');</script>0~3.htm代码随意!这里,b.htm借用了孟子斑竹网页上找到的,普通HTML模拟ASP的QUERYSTRING传递参数!我觉得这西西非常非常非常好! 还有没有别的办法?比如window.location什么的?直接修改window.open打开的b.htm里面iframe的location?具体是否可以实现及其语法代码请大虾告知,谢谢 window.open()打开的?你可以用opener来取得a.htm里面的参数,再修改b.htm里面iframe的location.这样简单多了. a.htm代码:<input type=text id=inputid><input value=Open type=button onclick=openw()><script>function openw(){window.open('b.htm','newone');}</script>b.htm代码:<iframe id=ifrm></iframe><script>ifrm.location=window.opener.inputid.value;</script>思路就是这样,你自己再根据自己的情况修改修改就可以了! to:Estyle(靳田) b.htm 里面的iframe.location取决于点击的哪个连接阿~~b.htm里面又如何判断点的哪个连接呢? js中加按钮,初学求教! 帮忙看段代码如何改才能支持火狐浏览器 [悬赏求助]asp.net的js生成控件的事件问题 JavaScript极限难题 怎么获取点击浏览器BACK按钮事件? 获取td下所有的input节点值 小白又来麻烦大家了 跪求一个源码 checkbox问题 100 分求救 window.open 问题!!!!!! 请问如何用Javascript来获取指定页面源代码?高手求救! 高分求教,在线等待。 急,在线等……容易的问题
a.htm代码:
<a href=b.htm?ifrm=1.htm>Click to open 1.htm in Iframe</a><br>
<a href=b.htm?ifrm=2.htm>Click to open 2.htm in Iframe</a><br>
<a href=b.htm?ifrm=3.htm>Click to open 3.htm in Iframe</a>b.htm代码:
<iframe id=ifrmid></iframe>
<script>
function QueryString(sName)
{
var sSource = String(window.document.location);
var sReturn = "";
var sQUS = "?";
var sAMP = "&";
var sEQ = "=";
var iPos;
iPos = sSource.indexOf(sQUS);
var strQuery = sSource.substr(iPos, sSource.length - iPos);
var strLCQuery = strQuery.toLowerCase();
var strLCName = sName.toLowerCase();
iPos = strLCQuery.indexOf(sQUS + strLCName + sEQ);
if (iPos == -1)
{iPos = strLCQuery.indexOf(sAMP + strLCName + sEQ);if (iPos == -1) return "";}
sReturn = strQuery.substr(iPos + sName.length + 2,strQuery.length-(iPos + sName.length + 2));
var iPosAMP = sReturn.indexOf(sAMP);
if (iPosAMP == -1)
return sReturn;
else
{sReturn = sReturn.substr(0, iPosAMP);}
return sReturn;
}
ifrmid.location=QueryString('ifrm');
</script>0~3.htm代码随意!这里,b.htm借用了孟子斑竹网页上找到的,普通HTML模拟ASP的QUERYSTRING传递参数!
我觉得这西西非常非常非常好!
window.location
什么的?
直接修改window.open打开的b.htm里面iframe的location?
具体是否可以实现及其语法代码请大虾告知,谢谢
你可以用opener来取得a.htm里面的参数,再修改b.htm里面iframe的location.
这样简单多了.
<input type=text id=inputid><input value=Open type=button onclick=openw()>
<script>
function openw()
{window.open('b.htm','newone');}
</script>b.htm代码:
<iframe id=ifrm></iframe>
<script>
ifrm.location=window.opener.inputid.value;
</script>思路就是这样,你自己再根据自己的情况修改修改就可以了!
b.htm 里面的iframe.location取决于点击的哪个连接阿~~b.htm里面又如何判断点的哪个连接呢?