ITeye博客

URL参数过长时post 跳转的方法(form替换location.href)

chengtong_java · 2015-07-07 18:28 · javascript · Web前端 · Markdown

在页面跳转时,我们时常用 window.location.href  的方法,如下:

window.location.href = 'monitor/queryalready_count?param_string='+param_string;

注意:window.location.href 的跳转是 get 的跳转方式

 

但是当参数param_string 过长时,比如参数字符串达到2K以上的长度,get跳转显然不可能了,就要使用form表单的形式实现post的方式跳转,可以在js中用以下方法实现:

 

document.write("<form action='monitor/queryalready_count' method='post' name='count_form' style='display:none'>");
document.write("<input type='hidden' name='param_string' value='"+param_string+"'");
document.write("</form>");
document.count_form.submit();

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。