zoukankan      html  css  js  c++  java
  • returnValue的含义

     

    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数组,用来传递大量数据。

  • 相关阅读:
    firstresponder 后,键盘不显示
    performSelector
    setNeedsDisplay、setNeedsLayout 区别
    Xcode 工程文件打开不出来, cannot be opened because the project file cannot be parsed.
    GCD介绍(一):基本概念和dispatch queues
    一些概念
    /mnt/sdcard /sdcard
    eclipse 导入已存在的工程文件出错
    ios 常用技巧
    ios nsstring去掉换行符
  • 原文地址:https://www.cnblogs.com/lovablebox/p/973964.html
Copyright © 2011-2022 走看看