日期:2014-05-16  浏览次数:20389 次

各位帮个忙,有关iframe和form提交的问题,谢谢!
问题如下:
1.我如果用
var   iframe=   document.getElementById( "ifrm ");
alert(iframe.length);
for(var   i=0;i <iframe.lenth;i++){
      iframe[i].document.forms[ "frm1 "].submit();
}
这句话怎么写?我的是错的;
2.我点保存后,怎么才能导向d.jsp这个页面?     注:c.jsp和d.jsp可以用空白的测试.

    <iframe   id= "ifrm0 "     width=600   height= "94 "   MARGINHEIGHT= "0 "   MARGINWIDTH= "0 "   frameborder=0   border=0     src= "/c.jsp?id=0 "   scrolling=no> </iframe>
<iframe   id= "ifrm1 "     width=600   height= "94 "   MARGINHEIGHT= "0 "   MARGINWIDTH= "0 "   frameborder=0   border=0     src= "/c.jsp?id=1 "   scrolling=no> </iframe>
<input   type= "submit "   name= "btn1 "   value= "保存 "   onclick= "a() ">
<script   >
function   a   (){
//var   iframe=   document.getElementById( "ifrm ");
//alert(iframe.length);
//for()
document.frames[ "ifrm0 "].document.forms[ "frm1 "].submit();
document.frames[ "ifrm1 "].document.forms[ "frm1 "].submit();
document.location.href= "/d.jsp ";
}
</script>

------解决方案--------------------
ifrm0.document.frm1.submit();
ifrm1.document.frm1.submit();
------解决方案--------------------
for(var i=0;i <document.getElementsByTagName( 'iframe ')).length;i++)
{
document.frames[i].document.forms[ "frm1 "].submit();
}