<html>
<script language="javascript">
function openScript(url,name, width, height){
var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
</script>
<body bgcolor="#ffffff">
<a href=# onclick="openScript('sub1.html','pur',600,450)" >设备类型</a>
<input type=text name=type value="">
</body>
</html> <html>
<script lanuage="javascript">
function save()
{
var v=document.theForm.type.value;
parent.document.getElementById('s').innerHTML=v;
window.close();
}
</script><body>
<form name="theForm">
<tr><td>
<select name="type">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="store" value="保存" onClick="save()">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
</body>
</html>选中的值如何在原窗口中显示??
<script language="javascript">
function openScript(url,name, width, height){
var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
</script>
<body bgcolor="#ffffff">
<a href=# onclick="openScript('sub1.html','pur',600,450)" >设备类型</a>
<input type=text name=type value="">
</body>
</html> <html>
<script lanuage="javascript">
function save()
{
var v=document.theForm.type.value;
parent.document.getElementById('s').innerHTML=v;
window.close();
}
</script><body>
<form name="theForm">
<tr><td>
<select name="type">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="store" value="保存" onClick="save()">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
</body>
</html>选中的值如何在原窗口中显示??
window.opener.document.name.value= 选择的值;
怎么写都行
子页面传值的语句window.opener.document.getElementById('type').value=v;
照上面的修改一下就可以了
<script>
var rv = window.showModalDialog('2.htm');
alert(rv);
</script>2.htm中:
<script>
window.returnValue = 5;
</script>试一下
1.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=shift_jis" />
<title>js</title>
</head><body>
<form id="form1" name="form1" method="post" action="">
<p>
<input type="button" name="Button" value="Button" onclick="window.open('2.html','','width=500, height=250')"/>
</p>
<p>
<input type="text" name="textfield" readonly="true"/>
</p>
</form>
</body>
</html>2.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=shift_jis" />
<title>js2</title>
<script>
function tranValue() {
window.opener.document.form1.textfield.value=document.form2.selectbox.value;
window.close();
parent.location.unload();
}
</script>
</head><body>
<form name="form2">
<select name="selectbox" onchange="tranValue()">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</form></body>
</html>你试一下
var returnTarget = window.showModalDialog(url, 'OtherItemInfo', 'dialogHeight:340px;dialogWidth:300px;resizeable:no;help:no;status:no;scroll:no');
子窗口中的代码:
window.returnValue = form.select.value; //选择的值