乡镇综治例会记录:请问:在网页中如何获取其嵌入页的一个隐藏文本框的值??

来源:百度文库 编辑:中科新闻网 时间:2024/05/07 18:35:14

假定你的iframe定义如下:

<iframe id=hid src=a.asp></iframe>

而a.asp里有一个文本框定义如下:

<input type=hidden name="txt" value="123">

那么在主页面里调用txt的值的方法如下:

<script language="javascript">

var tmp;
var doc=window.frames["hid"].document;

doc.onreadystatechange=function(){

document.write(doc.getElementById("txt").value);

}

</script>

关键在于iframe里的页面加载完毕后才可以访问其中的对象,这个就需要靠onreadystatechange来判断了。

用JS:document.frame('xia').from1.text1.value就可以了。
其实中xia是你定义的那个iframe
<iframe name='xia' src='***.asp'></iframe>
楼主明白了吗?