当前位置: 代码迷 >> JavaScript >> 怎么给框架页传值?帮帮忙了!
  详细解决方案

怎么给框架页传值?帮帮忙了!

热度:88   发布时间:2012-02-23 22:01:35.0
如何给框架页传值?帮帮忙了!急!
在一个框架页中连有另外一个页面,比如是a.html,现在想将框架页中的字符串传给a.html,请问应该怎样实现?

------解决方案--------------------
可以用window.frames[ "id "]取得子祯,然后调用子页面中的函数
window.frames[ "id "].functionname(parameters)
具体细节试一下吧
------解决方案--------------------
<body>
<iframe id= "s " src= "9.htm "> </iframe>
<input type= "button " onclick= "c() " value= "transfer parameter to 9.htm ">
</body>
<script>
function c()
{

if(document.all.s.readyState== "complete ")
{
window.frames[ "s "].window.h( "1234 ");
window.frames[ "s "].document.getElementById( "a ").value= "aaaaaa ";

}

}
//document.all.s.onreadystatechange=c;
</script>

<!--9.htm -->
<input type=text id= "a " name= "a " value= " "/>
<script>
function h(x)
{
alert(x);
}
</script>
------解决方案--------------------
是不是这种效果?

<frameset rows= "80,* " frameborder= "no " border= "0 " framespacing= "0 ">
<frame src= "a.html?mystr=abcdef " name= "topFrame " scrolling= "No " noresize= "noresize " id= "topFrame " />
<frame src= "b.html " name= "mainFrame " id= "mainFrame " />
</frameset>


a.html

<script>
function getPram(source, name)
{
var reg = new RegExp( "(^|\\?|&) "+ name + "=([^&]*)(\\s|&|$) ", "i ");

if (reg.test(source)) return RegExp.$2; return " ";
}
var vu=location.href
var mystr=getPram(vu, "mystr ");
alert(mystr);
</script>
  相关解决方案