js实现post方式提交并打开新窗口

/**
 * js实现post方式提交打开新窗口
 * @param URL
 * @param PARAMS
 */
function postOpenWindow(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();
}
/**
 * 调用
 */
function getAction(id){
    $.post("${ctx}/global/user/getNavigate",{"navigate_id":id},function(data){
        postOpenWindow("${ctx}/global/user/iframe",{"userName":'${userName}',"userType":'${userType}'});
    })
}

Guess you like

Origin blog.csdn.net/peter_qyq/article/details/84857929