zoukankan      html  css  js  c++  java
  • javascript实现浏览器窗口传递参数

    a.html 

    Java代码  收藏代码
    1. <html>  
    2. <head>  
    3.     <title>主页面</title>  
    4.     <script language="javascript" type="text/javascript">  
    5.     function OpenNew()  
    6.     {  
    7.         var im=new IDAndMethod();  
    8.         im.ID=document.getElementById("txtID").value;  
    9.         window.showModalDialog("ddd.html",im,"");  
    10.     }  
    11.     function IDAndMethod()  
    12.     {  
    13.         this.ID="ddd";  
    14.         this.Method=SetTxt;  
    15.     }  
    16.     function SetTxt(str)  
    17.     {  
    18.         document.getElementById("txtID").value=str;  
    19.     }  
    20.     </script>  
    21. </head>  
    22. <body>  
    23.     <form action="#">  
    24.         <input id="txtID"  style="400px" type="text" value="XXX!在这里输入ID!" /><br />  
    25.         <input type="button" value="打开新的窗口" onclick="OpenNew()" />  
    26.     </form>  
    27. </body>  
    28. </html>  


    b.html 

    Java代码  收藏代码
    1. <html>  
    2. <head>  
    3.     <title>主页面</title>  
    4.     <script language="javascript" type="text/javascript">  
    5.     var im;  
    6.     function Load()  
    7.     {  
    8.         im=window.dialogArguments;  
    9.         if(im.ID=="XXX!在这里输入ID")  
    10.             document.getElementById("txtID1").value="你杂不输入呢!";  
    11.         else  
    12.             document.getElementById("txtID1").value=im.ID;  
    13.     }  
    14.     function Set()  
    15.     {  
    16.         im.Method(document.getElementById("txtID1").value);  
    17.     }  
    18.     </script>  
    19. </head>  
    20. <body onload="Load()">  
    21.     <form action="#">  
    22.         <input id="txtID1" style="400px" type="text" value="ddd"  /><br />  
    23.         <input type="button" value="传递数据" onclick="Set()" />  
    24.     </form>  
    25. </body>  
    26. </html>  
  • 相关阅读:
    【POJ】【2420】A Star not a Tree?
    【BZOJ】【2818】Gcd
    【BZOJ】【2190】【SDOI2008】仪仗队
    【Vijos】【1164】曹冲养猪
    【BZOJ】【1430】小猴打架
    【BZOJ】【3611】【HEOI2014】大工程
    【转载】完全图的生成树
    【BZOJ】【2286】【SDOI2011】消耗战
    【POJ】【1061】/【BZOJ】【1477】青蛙的约会
    Codeforces VK Cup Finals #424 Div.1 A. Office Keys(DP)
  • 原文地址:https://www.cnblogs.com/ranzige/p/3910538.html
Copyright © 2011-2022 走看看