框家内页值传递不过去是怎么回事.
框家内页值传递不过去是怎么回事.
我用top.
一个页: 01.htm
<input type= "text " id= "txt_1 " name= "txt_1 ">
<iframe id= "iframe " name= "iframe " width= "50% " height= "40 " src= "02.htm "> </iframe>
02.htm
<script language= "javascript ">
function getpar(str)
{
top.document.getelemetnById( "txt_image ").value=str; //这样怎么不行啊
}
</script>
<a href= "# " inclick= "getpar( '00 '); "> 传递不过去值 </a>
因该怎么写才能把02.htm把值传递到01.htm 啊。也就是写入到01.htm里面的文本框里面去啊。
------解决方案--------------------请参考以下代码:
01.htm
<form name= "form1 " action= " " method= "post ">
<input type= "text " id= "txt1 " name= "txt1 ">
</form>
<iframe id= "iframe " name= "iframe " width= "50% " height= "40 " src= "02.htm "> </iframe>
02.htm
<script language= "javascript ">
function getpar(str)
{
window.parent.document.form1.txt1.value=str; //这样怎么不行啊
}
</script>
<a href= "# " onclick= "getpar( '00 '); "> 传递不过去值 </a>
------解决方案--------------------01.htm
<input type= "text " id= "txt1 " name= "txt1 ">
<iframe id= "iframe " name= "iframe " width= "50% " height= "40 " src= "02.htm "> </iframe>
02.htm
<script language= "javascript ">
function getpar(str) {
window.top.document.getElementById( "txt1 ").value = str;
}
</script>
<a href= "# " onclick= "getpar( '00 '); "> 传递过去 </a>