父窗口获取子窗口的值

father.jsp
<script type="text/javascript">
	function openWindow() {
			var _url = "${pageContext.request.contextPath}/son.jsp";
			var rtnstr = window.showModalDialog(_url,null,"dialogHeight=635px;dialogWidth=690px;");
			if(rtnstr != undefined && rtnstr != '') {
				father.value = rtnstr;
			}
	}
	</script>
	</head>
	<body> 
		<input type="text" name="father" value="" />
		<input type="button"
			onclick="openWindow();" value="提交"/>
		<br> 
	</body> 

son.jsp
<script type="text/javascript">
	function sub() {
		var _son = document.getElementById("son").value;
		alert("son:"+_son);
		window.returnValue = _son;
		window.close();
	} 
	</script>

  </head>
  
  <body>
   <input type="text" name="son" value="" id="son"/>
   <input type="button"
			onclick="sub();"  value="提交"/>
  </body>

你可能感兴趣的:(JavaScript,jsp)