父窗口代码--------------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function shownewpage(thisurl){
window.open(thisurl,"弹出页面","width=200,height=60,scrollbars=yes,resizable=no");
}
</script>
</head><body>
<form name="parentform">
<input type="button" value="选择信息" onclick="shownewpage('content.html');" /><br />
选择的结果:<input type="text" name="result" />
</form>
</body>
</html>
子窗口代码--------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function returnValue(){
var city=document.myform.city.value;
var doc=window.opener.document;
doc.parentform.result.value=city;
window.close();
}
</script>
</head><body>
<form name="myform">
选择:
<select name="city">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="深圳">深圳</option>
<option value="广州">广州</option>
</select>
<input type="button" value="返回" onclick="returnValue();" />
</form>
</body>
</html>
----------------------------
点返回后无反应正常是应该关闭子窗口的啊JavaScriptHTML函数
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function shownewpage(thisurl){
window.open(thisurl,"弹出页面","width=200,height=60,scrollbars=yes,resizable=no");
}
</script>
</head><body>
<form name="parentform">
<input type="button" value="选择信息" onclick="shownewpage('content.html');" /><br />
选择的结果:<input type="text" name="result" />
</form>
</body>
</html>
子窗口代码--------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function returnValue(){
var city=document.myform.city.value;
var doc=window.opener.document;
doc.parentform.result.value=city;
window.close();
}
</script>
</head><body>
<form name="myform">
选择:
<select name="city">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="深圳">深圳</option>
<option value="广州">广州</option>
</select>
<input type="button" value="返回" onclick="returnValue();" />
</form>
</body>
</html>
----------------------------
点返回后无反应正常是应该关闭子窗口的啊JavaScriptHTML函数
function shownewpage(thisurl){
window.open(thisurl,"弹出页面","width=200,height=60,scrollbars=yes,resizable=no");
}window.open是没有返回值的
应改为:
var city=window.showModalDialog(thisurl,"弹出页面","width=200,height=60,scrollbars=yes,resizable=no");错误2:function returnValue(){
var city=document.myform.city.value;
var doc=window.opener.document;
doc.parentform.result.value=city;
window.close();
}
改成
var city=document.myform.city.value;
window.returnValue =city;
window.close();这样在当子页面关闭的时候会将city返回到主页面
主页面alert(city)就可以接收到值!
在chrome下需要配置为站点才可以,
至于2楼的方法,showModalDialog有些游览器是不支持的