Javascript中的windows窗口对象

来源:互联网 发布:centos 7 乱码 编辑:程序博客网 时间:2024/05/19 04:55

1:window.html

<!DOCTYPE htm><html lang="en"><head>    <meta charset="UTF-8">    <title>windows窗口对象</title>    <script type="text/javascript">    </script></head><body>编号:<input type="text" name="numId" id="numId"/><br/>姓名:<input type="text" name="nameId" id="nameId"/><br/><input type="button" value="选择" onclick="open1();"/><script type="text/javascript">    //实现弹出窗口的方法   function  open1() {       window.open("user.html","","width=240,height=240");   }</script></body></html>
2:user.html
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title></head><body><table border="1" bordercolor="orange" width=200" height="200">    <tr align="center">        <td>操作</td>        <td>编号</td>        <td>姓名</td>    </tr>    <tr align="center">        <td><input type="button" value="选择" onclick="s1('0010','张三');"/></td>        <td>0010</td>        <td>张三</td>    </tr>    <tr align="center">    <td><input type="button" value="选择" onclick="s2('0011','李四');"/></td>    <td>0011</td>    <td>李四</td></tr>    <tr align="center">        <td><input type="button" value="选择" onclick="s3('0012','王五');"/></td>        <td>0012</td>        <td>王五</td>    </tr></table><script type="text/javascript">function s1(num1,name1) {    //把num,name赋给window页面   var pwindow=window.opener//得到父窗口 window.opener    pwindow.document.getElementById("numId").value=num1;    pwindow.document.getElementById("nameId").value=name1;}function s2(num2,name2) {    var pwindow=window.opener//得到父窗口 window.opener    pwindow.document.getElementById("numId").value=num2;    pwindow.document.getElementById("nameId").value=name2;}function s3(num3,name3) {    var pwindow=window.opener//得到父窗口 window.opener    pwindow.document.getElementById("numId").value=num3;    pwindow.document.getElementById("nameId").value=name3;}</script></body></html>


0 0
原创粉丝点击