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

16 篇文章 0 订阅

Google

<script type="text/javascript"> 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"; </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

问:如何得到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" οnclick="alert(frames['iEditor'].sContent)">
<input type="button" value="get iframe value" οnclick="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 οnclick="alert(iEditor.document.all.txt.value)">
<br>
<INPUT type="button" value="显示变量值" id=button2 name=button2 οnclick="alert(iEditor.name)">
----------------------------------------------------------------------
editor.htm
<script language=javascript>
var name="ssm1226";
</script>
<input type=text name=txt value="ssm1226">
 


<script type="text/javascript"> 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"; </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值