在页面跳转时,我们时常用 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();
本文详细介绍了在JavaScript中处理长参数时,从GET跳转到POST跳转的方法,通过使用隐藏表单来解决参数长度限制问题。
6万+

被折叠的 条评论
为什么被折叠?



