<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>