iframe获得父页面的元素

主页面ifmain.htm:

 
<table width="60%" border="0">
<tbody>
<tr>
    <td>演示:</td>
    <td><input name="demo" id="demo" type="text" id="pname" size="40" maxlength="255" value="default" /></td>
</tr>
<tr>
    <td>IFRAME:</td>
    <td>
	<iframe id="upframe" width="100%" height="36" frameborder="0" scrolling="no" src="if.htm" /></iframe>
    </td>
</tr>
</tbody>
</table>


IFRAME页面if.htm:

<script>function change(){alert("原始值:"+parent.document.getElementById("demo").value); parent.document.getElementById("demo").value="成功改变";}</script>
<input name="test" type="button" onclick="change()" value="改变" />

你可能感兴趣的:(java)