//有些某些浏览器安全级别比较高,因为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
时间: 2024-12-27 10:42:26