HTML Form Target directed to IFRAM working in FF b

2019-08-29 10:58发布

问题:

I have a form which consists of two different targets. One target submits the form and the other presents a preview of the form data. My only issue here is that my logic works fine in firefox however the iframe in which the preview is to be displayed remains blank when I click the preview button. I've also noticed the form data being listed in the parent URL(text fields,selections ,etc...) , which shouldn't happen since the target is pointing to the iframe and not the parent. I've changed my security settings in IE and have confirmed that iframes do function correctly under normal circumstances. Any suggestions on what I could be doing wrong?

The Form logic:

<form name="sourceConfigForm" onSubmit="return OnSubmitForm();return false;">
...
<INPUT TYPE="SUBMIT" name="Operation" onClick="document.pressed=this.value" VALUE="Submit">
<INPUT TYPE="SUBMIT" name="Operation" id="previewButton" "onClick="document.pressed=this.value" VALUE="Preview XML">
</form>

The IFRAME Declaration:

<IFRAME SRC="" NAME="previewFrame" id="previewFrame"  WIDTH="300px" HEIGHT="400px" FRAMEBORDER="0"></IFRAME>

The java script called on form submission:

 function OnSubmitForm()
 {
   if(document.pressed == 'Preview XML')
   { 

     document.sourceConfigForm.target='previewFrame';
      //action calls spring controller
     document.sourceConfigForm.action ="XMLPreview"; 
   }
   else
   if(document.pressed == 'Submit')
   {
     document.sourceConfigForm.target="";
      //action calls spring controller
     document.sourceConfigForm.action ="AddSourceConfig";
   }
 }

回答1:

Keep the Iframe within form tag, atleast this worked for me.