见代码script_windowdemo_06.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Windows.Open Test</title>
<script type="text/javascript">
function shownewpage(thisurl){
var returnValue=window.showModalDialog(thisurl);
document.getElementById("myvalue").value=returnValue;
}
</script></head><body>
<form action="" method="get" name="parentform"> <input name="" type="button" value="选择信息" onclick="shownewpage('contentY.html');" />
<input name="result" type="text" id="myvalue" />
</form>
</html>contentY.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Windows.Open Test</title>
<script type="text/javascript">
function returnValue(){
window.returnValue=document.getElementById("city").value;
window.close();
}
</script></head><body>
<form action="" method="post" name="myform"><select name="city" id="city">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="深圳">深圳</option></select><input name="" type="button" value="返回" onclick="returnValue()" /></form>
</body>
</html>取得的值是 undefined 为何呀!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Windows.Open Test</title>
<script type="text/javascript">
function shownewpage(thisurl){
var returnValue=window.showModalDialog(thisurl);
document.getElementById("myvalue").value=returnValue;
}
</script></head><body>
<form action="" method="get" name="parentform"> <input name="" type="button" value="选择信息" onclick="shownewpage('contentY.html');" />
<input name="result" type="text" id="myvalue" />
</form>
</html>contentY.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Windows.Open Test</title>
<script type="text/javascript">
function returnValue(){
window.returnValue=document.getElementById("city").value;
window.close();
}
</script></head><body>
<form action="" method="post" name="myform"><select name="city" id="city">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="深圳">深圳</option></select><input name="" type="button" value="返回" onclick="returnValue()" /></form>
</body>
</html>取得的值是 undefined 为何呀!
把名字改下,不要用returnValue,它会把window.returnValue当成你定义的方法。