码迷,mamicode.com
首页 > Windows程序 > 详细

window打开新窗口案例

时间:2017-07-13 19:11:42      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:点击   情况   分享   pen   cli   value   window   .com   logs   

//有些某些浏览器安全级别比较高,因为js的安全性,所以会出现不能访问本地文件的现象,但是实际开发中是不会存在这种情况,因为用的是域名,不是本地文件地址。
<html>
 <head>
  <title>Html示例</title>
 </head>
 <body>
 编号:<input type="text" id ="numid"/><br/>
 姓名:<input type="text" id ="nameid"/><br/>
 <input type ="button" value ="选择" onclick="open1()"/>
<script type ="text/javascript">
function open1() {
window.open("user.html","","width=250,height=150");
}

</script>

 </body>
</html>

 

 下面是 user.html的代码

<html>
 <head>
  <title>Html示例</title>
 </head>
 <body>
 <table border="1" bordercolor="blue">
 <tr>
    <td>操作</td>
    <td>编号</td>
    <td>姓名</td>
 </tr>
 <tr>
    <td> <input type ="button" value ="选择" onclick="open2(‘100‘,‘张三‘);"/></td>
    <td>100</td>
    <td>张三</td>
 </tr>
 <tr>
    <td> <input type ="button" value ="选择" onclick="open2(‘101‘,‘李四‘);"/></td>
    <td>101</td>
    <td>李四</td>
 </tr>
 <tr>
    <td> <input type ="button" value ="选择" onclick="open2(‘102‘,‘王五‘);"/></td>
    <td>102</td>
    <td>王五</td>
 </tr>
 </table>
<script type ="text/javascript">
 function open2(num1,name1) {
 var pwin = window.opener;
 pwin.document.getElementById("numid").value =num1;
 pwin.document.getElementById("nameid").value =name1;
 window.close();
 }

</script>

 </body>
</html>

  结果显示为技术分享  点选择会出现技术分享 点击图2的选择 编号和姓名会显示在图1

window打开新窗口案例

标签:点击   情况   分享   pen   cli   value   window   .com   logs   

原文地址:http://www.cnblogs.com/zengjiao/p/7161729.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!