JS中一個window.showModalDialog的應用原碼

來源:互聯網
上載者:User

1、父視窗(也即用來控制快顯視窗的那個頁面)
parent.html
---------------------------------------------------------------------------------------

<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>showModalDialog</title>
  <script language="JavaScript">
   var aInfo  = new Array(3);
   aInfo[0] = "I";
   aInfo[1] = "love";
   aInfo[2] = "windy";
   var url = "son.html";
   var sFeatures = "dialogWidth=500px;dialogHeight=500px;dialogLeft=0;dialogTop=0;";

   function showDialog(){
    var returnValue = window.showModalDialog(url,aInfo,sFeatures);
    if(returnValue!=null){
                       //  for(var i=0;i<returnValue.length;i++){
                       //    document.all.info.innerHTML = returnValue[i]+"<br>";
                       //    }
     document.all.info.innerHTML=returnValue;
    }
   }
  </script>
 </head>
 <body>
  <h3>
   <a href="#" onclick="showDialog()">開啟Dialog視窗</a>
  </h3>
  <div id="info"></div>
 </body>
</html>

2、子視窗(即將被彈出的那個頁面)
son.html
-----------------------------------------------------------------------------------------

<html>
 <head>
  <title>Dialog</title>
 </head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <body>
  <script language="JavaScript">
   var args = window.dialogArguments;
   if(args!=null){
     for(var i=0;i<args.length;i++){
       document.writeln(args[i]);
     }
   }
   else{
     document.writeln("對不起,參數為空白");
   }
   window.returnValue = "這是子視窗返回來的值";
  </script>
 </body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.