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

隐藏的iframe中,form的submit总是失败
在main_editor.html中,有以下代码:

function   c_editor_save_prvw()
{
var   str   =   " <{$action}> ";
var   id   =   str.substring(str.lastIndexOf( '= '),   str.length);

frames[ 'sub_content_prvw '].document.getElementById( 'content_p ').value   =   frames[ 'x '].document.body.innerHTML.replace(/ <!----> /g,   ' ');         //有值,并且正确
frames[ 'sub_content_prvw '].document.getElementById( 'sub_prvw ').action   =   'wap_page.php?op=editor_save_prvw&id '+id;         //地址是对的,浏览器中单独执行此地址没问题
frames[ 'sub_content_prvw '].document.sub_prvw.submit();         //失败
}
//-->
</script>
<iframe   id= "sub_content_prvw "   width= "0 "   height= "0 "   src= "../admin/sub_content_prvw.php "   domain= "localhost "> </iframe>


sub_content_prvw.php(之所以命名为.php文件,主要是为解决iframe拒绝访问的问题)的内容如下:

<form   id= "sub_prvw "   name= "sub_prvw "   method= "post ">
<input   type= "hidden "   id= "content_p "   />
</form>


为什么呢?怎么解决呢?

------解决方案--------------------
submit();
是不是后边中文分号的问题?
------解决方案--------------------
一个是小梅说的分号
还有
frames[ 'sub_content_prvw '].document.getElementById( 'sub_prvw ').action = 'wap_page.php?op=editor_save_prvw&id '+id;
这句改下
frames[ 'sub_content_prvw '].document.sub_prvw.action
------解决方案--------------------
function c_editor_save_prvw()调用了吗?
------解决方案--------------------
参考

PAGE A:
<script>
var iframeObj = document.getElementById( "workFrame ");
function changeDiv(){
iframeObj.src= "url page b ";
}
function changeFrom(){
document.formName.target= "workFrame ";
document.formName.submit();
}
</script>
<input type= "button " name= " " value= "Change Div " onclick= "changeDiv(); ">
<input type= "button " name= " " value= "Form div " onclick= "changeFrom(); ">

<DIV id= "divId ">
Main page Content
</DIV>
<Form id= "formId " name= "formName " action= "url page b ">

</Form>
<iframe id= "workFrame " width= "0 " height= "0 " src= " ">

PAGE B ,iframe result page:

<DIV id= "divId ">
iframe page result content .
</DIV>
<script>
try{
var div = document.getElementById( "divId ");
var parent_div = parent.document.getElementById( "divId ");
if(div){
parent_div.innerHTML = div.innerHTML;
}
}catch(e){
alert(e);
}
</script>
------解决方案--------------------
回复人:hbhbhbhbhb1021(天外水火(我要多努力)) ( 四星(高级)) 信誉:100 2007-6-7 20:46:43 得分:0
?

一个是小梅说的分号
还有
frames[ 'sub_content_prvw '].document.getElementById( 'sub_prvw ').action = 'wap_page.php?op=editor_save_prvw&id '+id;