js使用post 方式打开新窗口,隐藏Url参数

要想在地址栏隐藏url传递的参数,不能直接隐藏,但有几下几个变通的方法. 使用类似Base64编码,将URL参数进行简单加密. 使用框架页; 使用POST方式传递数据; 使用Cookie传递数据;

下面主要介绍模拟表单提交的post方式:

function post(URL, PARAMS) {
        var temp_form = document.createElement("form");
        temp_form.action = URL;
        temp_form.target = "_blank";
        temp_form.method = "post";
        temp_form.style.display = "none";
        for (var x in PARAMS) {
            var opt = document.createElement("textarea");
            opt.name = x;
            opt.value = PARAMS[x];
            temp_form .appendChild(opt);
        }
        document.body.appendChild(temp_form);
        temp_form.submit();
    }

注意:如需新打开窗口 form 的target属性要设置为'_blank'

然后请求

post('${contextPath}/analyse/detail.do',{carNum :carNum,ids:refIds});

就可以了

原文地址:https://www.cnblogs.com/huxiaolin/p/4988779.html