showModalDialog 访问父窗口,向父窗口返回值及undefined类型判断,js触发服务器控件事件

访问父窗口:

        var parent=window.dialogArguments;
        //  父页面路径
        //frmAction.ActionReturnURL.value = parent.location;
        //  父页面表名--导出页面所需的参数
        var TableName=parent.document.getElementsByName("TableName")[0].value;
        //  父页面记录条数
        var dcjet_RowCount=parent.document.getElementsByName("dcjet_RowCount")[0].value;
        //  父页面查询条件
        var dcjet_CommonWhere=parent.document.getElementsByName("dcjet_CommonWhere")[0].value;
        //  导出字段
        var FIELD_ID = getSelectList(document.all[strIDFieldName]);
        //  排序
        var OrderBy=parent.document.getElementsByName("OrderBy")[0].value;
        //  查询
        var Filter=parent.document.getElementsByName("Filter")[0].value;
        //  版本
        var Version=parent.document.getElementsByName("Version")[0].value;
        //  文件名
        var FileName=parent.document.getElementsByName("FileName")[0].value;
        //  页面ID
        var ReportID=parent.document.getElementsByName("ReportID")[0].value;
        //  模块名
        var ModelName=parent.document.getElementsByName("ModelName")[0].value;
        //  StartRows
        var StartRows=parent.document.getElementsByName("StartRows")[0].value;
        //  ActionReturnURL
        var ActionReturnURLa=parent.location.toString();//parent.document.getElementsByName("ActionReturnURL")[0].value;
        ActionReturnURL=ActionReturnURLa.replace(/&/g, "%26");
//        ActionReturnURLa="http://localhost/TCms/Admin/BillManage/BillVindicate/Index.aspx?ReportID=8501&IE_FLAG=I&G_MARK=3"
//        ActionReturnURL=ActionReturnURLa.replace(/&/g, "%26");//正则表达式将&包含在路径中传递
//	改变父窗口路径
window.dialogArguments.location = "<%=Request.ApplicationPath %>/IEData/ExportDB_Common.aspx?isTemplate=1&TableName="+TableName+"&dcjet_RowCount="+dcjet_RowCount+"&dcjet_CommonWhere="+dcjet_CommonWhere +"&FIELD_ID="+FIELD_ID+"&OrderBy="+OrderBy+"&Filter="+Filter+"&Version="+Version+"&FileName="+FileName+"&ReportID="+ReportID+"&ModelName="+ModelName+"&StartRows="+StartRows+"&ActionReturnURL="+ActionReturnURL;
undefined类型判断:需要用typeof
if (typeof (returnResult) != "undefined") {
    window.document.getElementById("txtExportReportID").value = returnResult;
    window.document.getElementById("btnTxtHidden").click();
}
向父窗口返回值:
——子窗口:返回FIELD_ID值,之后子窗口关闭
window.returnValue=FIELD_ID;
            window.close();
——父窗口:用returnResult去接受返回值
var returnResult = showModalDialog(url, window,"help:No;resizable:No;status:No;scroll:yes");
js触发服务器控件事件及赋值:
window.document.getElementByID("服务器控件ID").value=值
注:为value赋值时,当心控件本就没有value属性,那会没用的
window.document.getElementById("txtExportReportID").value = returnResult;
window.document.getElementById("btnTxtHidden").click();

IE6中的showModelDialog中,<base target="_self" />不能直接在<head>下面,否则会报"xxxxx不能打开Interner站点,xxxxxxx"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在JavaScript中,可以使用不同的方式来实现点击事件打开新窗口。其中一种方式是在原来的窗口上打开新窗口,可以使用`window.location`属性来实现。例如,可以使用以下代码来实现点击按钮打开新窗口: ```html <input type="button" value="点击我看看效果" onclick="window.location='http://linlizhu.cn'" /> ``` 另一种方式是在新打开的窗口上打开新窗口。可以使用`window.open`方法来实现。例如,可以使用以下代码来实现点击按钮在新窗口中打开新窗口: ```html <input type="button" value="点击我看看效果" onclick="window.open('http://linlizhu.cn')" /> ``` 还有一种方式是在新打开的一块小窗口上打开新窗口,这种窗口没有菜单栏。可以使用`window.showModalDialog`方法来实现。例如,可以使用以下代码来实现点击按钮在新窗口中打开新窗口: ```html <input type="button" value="点击我看看效果" onclick="window.showModalDialog('http://linlizhu.cn')" /> ``` 以上是几种常见的方式,根据具体需求选择适合的方式来实现点击事件打开新窗口。 #### 引用[.reference_title] - *1* *2* *3* [JS点击按钮打开新的独立页面](https://blog.csdn.net/qq_26249609/article/details/84030665)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值