javascript 弹出的窗口返回值给父窗口具体实现

直接上代码,有些地方可以用到:

复制代码 代码如下:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META CONTENT="EditPlus">
<META CONTENT="">
<META CONTENT="">
<META CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function selectValue(){
    window.open("sub.html","","status:no;resizable:yes;dialogHeight:410px;dialogWidth:460px;unadorne:yes")
}
//-->
</SCRIPT>
</HEAD>

<BODY>
    text:<input type="text" /><br>
    <input type="button" value="选择" />
</BODY>
</HTML>

sub.html页面代码是

复制代码 代码如下:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META CONTENT="EditPlus">
<META CONTENT="">
<META CONTENT="">
<META CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function selectValues(){
   var obj = document.getElementsByName("temp");
   var value = "";
   for(var i = 0 ;i < obj.length ; i ++){
        if(obj[i].checked == true)
            value += obj[i].value;
   }
   window.opener.document.all.testInput.value = value;
   window.close();
}
//-->
</SCRIPT>
</HEAD>

<BODY>
    <input type="checkbox" value="A" />  A <br>
    <input type="checkbox" value="B"/>  B <br>
    <input type="checkbox" value="C" /> C <br>
    <input type="checkbox" value="D" />  D <br>
    <input type="button" value="OK"/>
</BODY>
</HTML>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdwxxd.html