如何得到iframe里的一个元素的值?
2007-10-19 13:04
441 查看
输入您的搜索字词 提交搜索表单 |
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";
相关文章推荐
- jquery 得到了this,如何获得到this下的一个元素
- java如何快速得到一个数组里面有多少种元素?
- 如何通过结构体中的任意一个元素的地址得到这个结构体的首地址(container_of)
- 如何获取一个dom元素的宽和高
- 定义栈的数据结构,要求添加一个 min 函数,能够得到栈的最小元素
- 如何在foreach中删除一个集合中的元素
- 利用 SHDocVw::IShellWindowsPtr m_spSHWinds 遍历所有IE浏览器,得到里面的所有元素 还有一个是查找IE窗口里的submit按钮,模拟点击
- 如何正确的在一个循环中删除ArrayList中的元素。
- 剑指offer-定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数。
- Java中如何循环删除一个集合(如List)中的多个元素
- 如何居中一个元素(二)(正常、绝对定位、浮动元素)?
- 如何判断一个整数数组中是否有重复元素
- js简单算法(二)如何去除一个数组中与另一个数组中的值相同的元素
- Java中如何删除一个集合中的多个元素
- 如何得到一个ACCESS数据库的所有表名
- 如何利用jquery从父页面取到iframe里面的元素
- 对于一个整数矩阵,存在一种运算,对矩阵中任意元素加一时,需要其相邻(上下左右),某一个元素也加一,现给出一正数矩阵,判断其是否能够由一个全零矩阵经过上述运算得到。
- 如何让一个元素自适应屏幕的高度
- 定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数。
- 如何判断一个整数数组中是否有重复元素?要求时间复杂度O(n),空间复杂度O(1)