1。 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My JSP 'example.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css"> --> </head> <body > <form action="" > <p id="changeValue" οnclick="change(test.my.innerHTML)" value="linwei">Click me!</p> <Iframe src="test.jsp" mce_src="test.jsp" id="test" width="250" height="200" scrolling="auto" frameborder="1" value="iframe"></iframe> <Iframe src="test1.jsp" mce_src="test1.jsp" id="test1" width="250" height="200" scrolling="auto" frameborder="1" value="iframe"></iframe> <h1 id="parentId" >hello,my wife</h1> <input type="text" value="aaa" οnkeypress="showKey()"></input> </form> </body> <mce:script type="text/javascript"><!-- function change(h) { //取得IFRAME里面的DOM对象 var obj = document.getElementById("test").contentWindow; //根据取得的对象,获取里面对应的 小对象 //1. var str = obj.document.getElementById("my").value; //2. alert("value is " + test.my.value); alert(str); } function showKey() { if(window.event.keyCode == 13) { alert("按钮是回车!"); } } // --></mce:script> </html> 2。 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <body> <h1 id="my" value="my" οnclick="show()"><font color="red">hello,my boy</font></h1> </body> <p>水电费是 <p id="oper" οnclick="oper()">撒地方</p> </html> <mce:script type="text/javascript"><!-- function show() { alert(parent.parentId.innerText); var obj = parent.parentId; obj.innerText = "linwei"; } function oper() { //Window.parent是用来在frame中进行操作的,在对话框中不能用来操作父窗口对象 var obj = parent.document.getElementById("test1").contentWindow; //alert("obj is " + obj); var str = obj.document.getElementById("my1").value; alert("value is " + str); } // --></mce:script> 3。 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <body> <h1 id="my1" value="my1" οnclick="show()"><font color="red">撒地方hello1,my1 boy1</font></h1> </body> </html> <mce:script type="text/javascript"><!-- function show() { alert(parent.parentId.innerText); var obj = parent.parentId; obj.innerText = "linwei"; } // --></mce:script>