get提交时url长度有限制

在html中get提交时,对url的长度是有限制的,当url的长度超过最大值时,页面就会停止提交。因此当有大数据量的数据要传输的时候要使用post方式提交。

当iframe中的src太长时的解决方案如下:

1、在父页面获得iframe的window对象。
2、往iframe里写入form表单,form表单使用post传输,并且写入要传递的大长度参数。
3、父页面控制iframe的form提交。
 父页面js部分代码如下:

var html = '<form action="'+url+'" method="post" target="_self" id="postData_form">'+
                 '<input id="hidden_longParam" name="longParam" type="hidden" value="'+参数值+'"/>'+
                '</form>';
document.getElementById('iframe的id').contentWindow.document.wirte(html);
document.getElementById('iframe的id').contentWindow.document.getElementById('postData_form').submit();


发布了16 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/a0604030212/article/details/9144371