html中子页面给父页面赋值,关闭子页面给父页面传值,父页面条件按子页面设置查询

[html]  view plain copy print ?
  1. father.html  
  2. <html>  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5. <title>father.html</title>   
  6. <script >  
  7. function assignment(content)  
  8. {  
  9.    document.getElementById("fvalue").value = content;//赋值  
  10. }  
  11. function openwindow(url,name,iWidth,iHeight)  
  12. {  
  13.     var url; //转向网页的地址;  
  14.     var name; //网页名称,可为空;  
  15.     var iWidth; //弹出窗口的宽度;  
  16.     var iHeight; //弹出窗口的高度;  
  17.     var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;  
  18.     var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;  
  19.     window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');  
  20. }   
  21. </script>  
  22. </head>   
  23. <body>  
  24. <input type="text" name="fvalue" id="fvalue" value="请按按钮设置条件" />  
  25. <br/>  
  26. <br/>  
  27. <input type="button" name="btn" value="父类<->设置条件" onclick="openwindow('sun.html','',200,80)"/>  
  28. </body>  
  29. </html>  
  30.   
  31.   
  32.   
  33. sun.html  
  34.   
  35. <html>  
  36. <head>  
  37. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  38. <title>sun.html</title>  
  39. <script>  
  40. function set()   
  41. {  
  42.     var value=document.getElementById('svalue').value;  
  43.     var data = window.opener.assignment(value);//给父类赋值  
  44.     window.close();  
  45. }  
  46. </script>  
  47. </head>  
  48.   
  49. <body>  
  50. <input type="text" name="svalue" id="svalue" value="" />  
  51. <br/>  
  52. <br/>  
  53. <input type="button" name="btn" value="子类<->赋值" onclick="set()"/>  
  54. </body>  
  55. </html>  

猜你喜欢

转载自blog.csdn.net/u012767263/article/details/46361233