returnValue的含義

來源:互聯網
上載者:User
 

returnValue是javascript中html的window對象的屬性,目的是返回視窗值,當用
window.showModalDialog函數開啟一個IE的強制回應視窗(強制回應視窗知道吧,就是開啟後不能操作父視窗,只能等強制回應視窗關閉時才能操作)時,用於返回視窗的值,下面舉個例子:

------------------------------------------------------------------------------
//father.html
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language="javascript">

function showmodal(){
 var ret = window.showModalDialog("child.htm",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no");
 if (ret){alert('子視窗返回真!');
 }else{
  alert('子視窗返回假!');
 }

}

</script>
</HEAD>
<BODY>
<INPUT id=button1 type=button value=Button name=button1 onclick="showmodal();">

</BODY>
</HTML>

------------------------------------------------------------------------------
//child.html
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language="javascript">
function trans(tag){

   if (tag==0){
     window.returnValue=false;
   } else{
     window.returnValue =true;
   }
   window.close();

}

</script>
</HEAD>
<BODY>

<INPUT id=button1 type=button value="返回真" name=button1 onclick="trans(1)">
<INPUT id=button2 type=button value="返回假" name=button2 onclick="trans(0)">

</BODY>
</HTML>
-----------------------------------------------------------------------------
這樣一來可以實現從強制回應視窗向父視窗傳遞值的作用,
這個returnValue除了可以是布爾值,整型值等以外還可以是個js數組,用來傳遞大量資料。

聯繫我們

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