zoukankan      html  css  js  c++  java
  • window.returnValue的使用例子

    [b] 今天接触了这个模态窗口的使用方法,看到这个window.returnValue字段,查了查资料,弄清楚了这个方法的使用,贴出来只为记忆,无其他想法。
    A界面 片段代码[/b]
    function selectRegion(branchNo,mobileNo,userName){

    var T_USER_ID="";
    if(GetCookie("userId"+<%=confId%>)!= null) {
    T_USER_ID=GetCookie("userId"+<%=confId%>);
    }
    var uri = "../Tree/BranchList.jsp?CompanyMobile=<%=companyMobile%>&BranchNo=" + branchNo + "&MobileNo=" + mobileNo + "&Name=" + userName+ "&T_USER_ID=<%=T_USER_ID%>";
    var selResult = window.showModalDialog(uri,"","center:1;status:0;help:0;resized:1;dialogheight:26;dialog62")
    //alert(selResult);
    if(!selResult || selResult == "")
    return;
    var unitArray = selResult.split(',');
    ReFundForm.BranchNo.value = unitArray[0];
    ReFundForm.MobileNo.value = unitArray[1];
    ReFundForm.Name.value = unitArray[2];
    ReFundForm.Dept.value = unitArray[3];
    }
    B界面 片段代码
    <script>
    function selectIt(str) {
    window.returnValue=str;
    window.close();
    }
    </script>
    ...
    提交<td width=52 height="23">
    <input type="radio" value="V1" name="R1"οnclick="selectIt('<%=s1%>,<%=s2%>, <%=s3%>,<%=s4%>')"> </td>
    ...

    [b] :) 这自己的代码很难看懂,看看我在网上以下查的实例,清楚明白些,呵呵
    注:以下非原创。[/b]


    fireForm.htm:点击“上传”按钮弹出内部窗口(showModalDialog),代码如下:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    function onObjMore(url,name,height,width,formName) {
    //window.alert(formName.file.type);
    var feature = "dialogWidth:"+width+"px;dialogHeight:"+height+"px;scroll:yes;status:no;help:no;center:1";
    var returnTarget = window.showModalDialog(url, name, feature);
    if(returnTarget != undefined && returnTarget.length > 1) {
    //document.location = returnTarget;
    formName.file.value=returnTarget;
    }
    return false;
    }
    </script>
    <link href="css/aljoin.css" rel="stylesheet" type="text/css">
    </head>

    <body>
    <form name="proForm" method="post" action="">
    <table width="400" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="93" height="25" style="white-space:nowrap " nowrap>文件</td>
    <td width="307" height="25"><input name="file" type="text" id="file"></td>
    </tr>
    <tr>
    <td height="25"> </td>
    <td height="25"><input type="button" name="Submit" value="上传文件" onClick="onObjMore('upfile.htm','upfile',300,300,proForm)"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>


    upfile.htm:点击”关闭”按钮返回window.returnValue值给opener,代码如下:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    function exit() {
    window.returnValue = "images/upload/2004080512.jpg";
    window.close();
    }
    </script>
    </head>
    <body>
    <input name="" type="button" value="关闭窗口" onClick="exit()">
    </body>
    </html>

    好的代码像粥一样,都是用时间熬出来的
  • 相关阅读:
    VSCODE打开一个文件,另一个文件就关闭的问题的解决方法
    elementui的el-tree第一次加载无法展开和选中的问题
    Java线程知识:二、锁的简单使用
    “商家参数格式有误”应用切微信H5支付完美解决方案
    git 基础操作,公私钥认证/ssh公私钥登录
    Python数据分析之亚马逊股价
    Python分析6000家破产IT公司
    Python数据分析之股票数据
    Python数据分析之全球人口数据
    Vue 面试重点真题演练
  • 原文地址:https://www.cnblogs.com/jijm123/p/15321368.html
Copyright © 2011-2022 走看看