Menu Close

JS 模拟页面 get/post 跳转

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

pageJump("/xxx/xxxxx", {paramsKey: paramsValue}, 'post');

发表评论

邮箱地址不会被公开。 必填项已用*标注

沪ICP备14006760号-2