iframe中src参数过长问题解决


iframe中src参数过长问题解决

 
这个自己没有试过,
 
iframe中src参数过长问题解决 


问题描述:iframe的src跳转页面是get提交,get提交在浏览器中最大限制在2k以内,超过2k就终止跳转,所以就想办法用post跳转。 


解决方法: 

1、在父页面获得iframe的window对象。 

2、往iframe里写入form表单,form表单使用post传输,并且写入要传递的大长度参数。 

3、父页面控制iframe的form提交。 



js 
var url = 'mubiao.jsp'; 

var data = '此处为大数据'; 

var html = '<form action="'+url+'" method="post" target="_self" id="postData_form">'+ 

                 '<input id="wor_iteId" name="wor_iteId" type="hidden" value="'+data+'"/>'+ 

                '</form>'; 

document.getElementById('ifr_1').contentWindow.document.wirte(html); 

document.getElementById('ifr_1').contentWindow.document.getElementById('postData_form').submit(); 

 

页面 

<iframe id="ifr_1"  src="about:blank"  width="100%" height="140px" noresize> 




JS刷新iframe 


有效方法: 

var myIfr = document.getElementById('q_ifr'); 

myIfr.src = myIfr.src; 





另外有用这个的 

document.frames('q_ifr').location.reload(); 

我在使用的时候在谷歌和火狐下没反应。 

要用还是用上面的那个好使。 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM