您的位置:首页 > 其它

如何得到iframe里的一个元素的值?

2007-10-19 13:04 441 查看


输入您的搜索字词 提交搜索表单
google_ad_client = "pub-5033576919944123";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2007-10-24: csdn.blog
google_ad_channel = "8548491739";

问:如何得到iframe里的一个元素的值?
例如:
<IFRAME src="editor.htm" name=iEditor width="100%" height="190">
</IFRAME>
在editor.htm里有一个sContent的变量,如何得到它的值?
______________________________________________________________________________________________
答1:
use frames['iEditor'].sContent, for example

1.editor.htm:
<script language="javascript">
sContent= 999;//this makes sContent part of window
</script>
<input id="txt1" value="123">

2. frame.htm:
<IFRAME src="editor.htm" name=iEditor width="100%" height="190">
</IFRAME>
<input type="button" value="get iframe variable" onclick="alert(frames['iEditor'].sContent)">
<input type="button" value="get iframe value" onclick="alert(frames['iEditor'].document.all('txt1').value)">
______________________________________________________________________________________________
答2:
index.htm

<IFRAME src="editor.asp" name=iEditor width="100%" height="190">
</IFRAME>
<INPUT type="button" value="显示text控件值" id=button1 name=button1 onclick="alert(iEditor.document.all.txt.value)">
<br>
<INPUT type="button" value="显示变量值" id=button2 name=button2 onclick="alert(iEditor.name)">
----------------------------------------------------------------------
editor.htm
<script language=javascript>
var name="ssm1226";
</script>
<input type=text name=txt value="ssm1226">

google_ad_client = "pub-5033576919944123";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2007-10-24: csdn.blog
google_ad_channel = "8548491739";
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐