iframe取值

来源:百度知道 编辑:UC知道 时间:2024/06/25 02:44:07
document.frames[id].test取不到值,在iframe的js中声明了一个变量var test="aaaaa";怎么在主页面取到iframe中的test值?

<script>
function test(){
alert(window.frames['tf'].str);
}
</script>
<iframe id="tf" border=0 marginwidth=0 framespacing=0 marginheight=0 src="1.html" frameborder=0 noresize width=778 scrolling=no height=95 vspale="0" allowtransparency onload="test()">

上面是主页面

<table width="100%" border="0" cellspacing="0" cellpadding="0" id="test">
<tr>
<td>sdsd</td>
</tr>
</table>
<script language="JavaScript">
var str = "str";
</script>
这个是窗口页面
已经测试过