发表时间:2009-02-05
最后修改:2009-02-25
【parentWin.html】
<HTML>
<HEAD>
<SCRIPT>
var ReturnValue ="";
function fnOpen()
{
ReturnValue =window.showModalDialog("childWin.html","childWin","status:false;dialogWidth:300px;dialogHeight:300px");
if(ReturnValue!="")
{
document.frm0.txt0.value=ReturnValue;
}
}
function show_chlidWinParam()
{
//var ss = ReturnValue.split(",");
document.frm0.txt0.value=ReturnValue;
}
</SCRIPT>
</HEAD>
<BODY>
<form name=frm0>
<input type=button value="打开模式窗口" onclick="fnOpen();"/>
<input type="text" name="txt0" >
</form>
<BODY>
</HTML>
====================================================================
====================================================================
【childWin.html】
<script>
function choseItem()
{
var v="";
var check_item = document.frm.item;
for(i=0;i<check_item.length;i++)
{
if(check_item[i].checked)
{
v+=","+check_item[i].value;
}
document.frm.txt.value=v.replace(/^,{1}/,"");
}
}
function foo()
{
window.close();
// window.opener.document.getElementById("txt0").value=document.getElementById("txt").value
window.returnValue = document.getElementById("txt").value;
}
</script>
<body>
<form name=frm>
<input type=checkbox name=item value=1 onclick="choseItem();">a
<input type=checkbox name=item value=2 onclick="choseItem();">b
<input type=checkbox name=item value=3 onclick="choseItem();">c
<input type=checkbox name=item value=4 onclick="choseItem();">d
<input type=text name="txt">
</form>
<input type=button value="关闭" onclick="foo();">
</body>