javascript實現瀏覽器視窗傳遞參數

來源:互聯網
上載者:User

標籤:style   blog   http   java   io   資料   for   ar   

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="width: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="width:400px" type="text" value="ddd"  /><br />  
  23.         <input type="button" value="傳遞資料" onclick="Set()" />  
  24.     </form>  
  25. </body>  
  26. </html>  
  • 模態.rar (1 KB)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.