js window.open隐藏参数提交

1.采用form方式提交

var  url = "page/public/exportExcel.jsp";
//create a form  
        var tempForm = document.createElement("form");    
        tempForm.id="tempForm1";  
        //set the way of sending request
        tempForm.method="post";
        //tempForm.accept-charset="UTF-8";        
        //the url is used for "window.open"��excute by action of form
        tempForm.action=url;  
        //bind the parameter for  "window.open" by attributes "target",such as window attributes
        tempForm.target="_blank";   
        //set the url para by creation of hidden elements 
        var hideInput = document.createElement("input");    
        hideInput.type="hidden";    
        hideInput.name= "title";  
        hideInput.value= title; 
        var hideInput2 = document.createElement("input");  
        hideInput2.type = "hidden";  
        hideInput2.name = "fields";
        hideInput2.value = fields;
        var hideInput3 = document.createElement("input");  
        hideInput3.type = "hidden";  
        hideInput3.name = "filename";
        hideInput3.value = outPutFileName;
        var hideInput3_1 = document.createElement("input");  
        hideInput3_1.type = "hidden";  
        hideInput3_1.name = "filetype";
        hideInput3_1.value = "xls";
        var hideInput4 = document.createElement("input");  
        hideInput4.type = "hidden";  
        hideInput4.name = "footer";
        hideInput4.value = footer;
        var hideInput5 = document.createElement("input");  
        hideInput5.type = "hidden";  
        hideInput5.name = "headers";
        hideInput5.value = JSON.stringify(headers);
        
        
        //if a crossTab,must send the content to server for downloading 
        if(this.reportTableType=="crossTable")
        {
            var hideTempInput1 = document.createElement("input");  
                hideTempInput1.type = "hidden";  
                hideTempInput1.name = "reportTableType";
                hideTempInput1.value = "crossTable";
                tempForm.appendChild(hideTempInput1);
                
            var hideTempInput2 = document.createElement("input");  
                hideTempInput2.type = "hidden";  
                hideTempInput2.name = "contents";
                hideTempInput2.value =JSON.stringify(contents) ;
                tempForm.appendChild(hideTempInput2);
        }
        //add  the base input-searchCondition
        for(var key in searchCondition){
            if($.trim(searchCondition[key])!=""){
                var hideTempInput = document.createElement("input");  
                hideTempInput.type = "hidden";  
                hideTempInput.name = key;
                hideTempInput.value = searchCondition[key];
                tempForm.appendChild(hideTempInput);
            }
        }
        //add the elements into form
        tempForm.appendChild(hideInput); 
        tempForm.appendChild(hideInput2);
        tempForm.appendChild(hideInput3);
        tempForm.appendChild(hideInput3_1);
        tempForm.appendChild(hideInput4);
        tempForm.appendChild(hideInput5);

        //add the form into the page body
        document.body.appendChild(tempForm); 
        //submit manually  
        tempForm.submit();
        //remove the temp form from the page body   
        document.body.removeChild(tempForm);

 

转载于:https://www.cnblogs.com/pu20065226/p/9804536.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值