• window.returnValue使用方法


       returnValue是javascript中html的window对象的属性,目的是返回窗口值,当用window.showModalDialog函数打开一个IE的模式窗口(模式窗口知道吧,就是打开后不能操作父窗口,只能等模式窗口关闭时才能操作)时,用于返回窗口的值,下面举个例子:

        1、parent.html

    Html代码  收藏代码
    1. //father.html  
    2. <HTML>  
    3. <HEAD>  
    4. <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">  
    5. <TITLE></TITLE>  
    6. <script language="javascript">  
    7.   
    8. function showmodal(){  
    9. var ret = window.showModalDialog("child.htm",null,"dialogWidth:350px;dialogHeight:350px;help:no;status:no");  
    10.     if (ret){alert('子窗口返回真!');  
    11.     }else{  
    12.          alert('子窗口返回假!');  
    13.    }  
    14. }  
    15. </script>  
    16. </HEAD>  
    17.   
    18. <BODY>  
    19. <INPUT id=button1 type=button value=Button name=button1 onclick="showmodal();">  
    20. </BODY>  
    21. </HTML>  

        2、child.html

    Html代码  收藏代码
    1. //child.html  
    2. <HTML>  
    3. <HEAD>  
    4. <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">  
    5. <TITLE></TITLE>  
    6. <script language="javascript">  
    7. function trans(tag){  
    8.    if (tag==0){  
    9.        window.returnValue=false;  
    10.    } else{  
    11.        window.returnValue =true;  
    12.   }  
    13.    window.close();  
    14. }  
    15. </script>  
    16. </HEAD>  
    17. <BODY>  
    18.   
    19. <INPUT id=button1 type=button value="返回真" name=button1 onclick="trans(1)">  
    20. <INPUT id=button2 type=button value="返回假" name=button2 onclick="trans(0)">  
    21.   
    22. </BODY>  
    23. </HTML>  

    总结:

           这样一来可以实现从模式窗口向父窗口传递值的作用,这个returnValue除了可以是布尔值,整型值等以外还可以是个js数组,用来传递大量数据。

            具体showModalDialog等的用法,可以参考msdn。

  • 相关阅读:
    随手
    会使用基本的Render函数后,就会想,这怎么用 v-for/v-if/v-model;我写个vue Render函数进阶
    iframe子页面与父页面元素的访问以及js变量的访问[zhuan]
    vue element-ui 的奇怪组件el-switch
    URLSearchParams和axios的post请求(防忘记)
    ios vue2.0使用html5中的audio标签不能播放音乐
    Unity Input System教程
    关于OpenGPU.org
    Better ultra_simple for Slamtec RPLIDAR on Linux
    八字心得
  • 原文地址:https://www.cnblogs.com/yzl495/p/4176001.html
Copyright © 2020-2023  润新知