美文网首页
JS 以POST方式打开新页面

JS 以POST方式打开新页面

作者: 简书mhy | 来源:发表于2018-10-31 15:15 被阅读0次
          /*
            *功能: JS跳转页面,并已POST方式提交数据
            *参数: URL 跳转地址 PARAMTERS 参数
            */
            function ShowReport_Click() {
    
                var parames = new Array();
                parames.push({ name: "param1", value: "param1"});
                parames.push({ name: "param2", value: "param2"});
    
                Post("SupplierReportPreview.aspx", parames);
    
                return false;
            }
    
            /*
            *功能: 模拟form表单的提交
            *参数: URL 跳转地址 PARAMTERS 参数
            */
            function Post(URL, PARAMTERS) {
                //创建form表单
                var temp_form = document.createElement("form");
                temp_form.action = URL;
                //如需打开新窗口,form的target属性要设置为'_blank'
                temp_form.target = "_self";
                temp_form.method = "post";
                temp_form.style.display = "none";
                //添加参数
                for (var item in PARAMTERS) {
                    var opt = document.createElement("textarea");
                    opt.name = PARAMTERS[item].name;
                    opt.value = PARAMTERS[item].value;
                    temp_form.appendChild(opt);
                }
                document.body.appendChild(temp_form);
                //提交数据
                temp_form.submit();
            }
    

    相关文章

      网友评论

          本文标题:JS 以POST方式打开新页面

          本文链接:https://www.haomeiwen.com/subject/fzeatqtx.html