Marydon20170307

CreateTime--2017年8月24日08:13:52
Author:Marydon

js实现页面跳转的两种方式

方式一:

  window.location.href = url

说明:我们常用来在js中实现页面跳转的方法,使用get方式发送请求,传参有限

更多介绍,见文章:js操作当前窗口  

方式二:

  通过POST请求实现页面跳转

/**
 * 发送POST请求跳转到指定页面
 * @param URL
 *         跳转路径
 * @param PARAMS
 *        参数:格式-JSON对象
 */
function httpPost(URL, PARAMS) {
    var temp = document.createElement("form");
    temp.action = URL;
    temp.method = "post";
    temp.style.display = "none";
    for (var x in PARAMS) {
        var opt = document.createElement("textarea");
        opt.name = x;
        opt.value = PARAMS[x];
        temp.appendChild(opt);
    }
    document.body.appendChild(temp);
    temp.submit();
    return temp;
}

 

 

 

分类:

技术点:

相关文章:

  • 2022-02-08
  • 2021-07-04
  • 2021-12-31
猜你喜欢
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
相关资源
相似解决方案