PDA

View Full Version : Hidden Iframe not working in IE


chandu2708
06-02-2009, 03:13 PM
Hi Coders,

Cpuold somebody help me on following case, what im trying to do here is create a dynamic hidden iframe and write a form into it and submit. this approach works in FireFox but not in IE7, below is the code im using

document.forms[form].appendChild(isProcessFQ);
var ifText = document.getElementById(rootElID).innerHTML;
var ifSubmit = document.createElement('iframe');
var ifSubmitID = 'inf-fq-process-' + sessionID;
ifSubmit.setAttribute('id',ifSubmitID);
ifSubmit.setAttribute('name',ifSubmitID);
ifSubmit.setAttribute('style','display: none');
document.getElementById(rootElID).appendChild(ifSubmit);
if(ifSubmit.contentDocument) {
doc = ifSubmit.contentDocument;
}else
if(ifSubmit.contentWindow) {
doc = ifSubmit.contentWindow;
}else
if (ifSubmit.document) {
doc = ifSubmit.document;
}
doc.open();
doc.write(ifText);
doc.close();
doc.forms[0].submit();

But when i run this in IE7 its openings a new blank window after the statement doc.open(); and shows some error(which has no useful details) and not maing any calls to server.

could somebody tell me how to fix this behaviour please.

Thank you,
bala.

adios
06-02-2009, 07:13 PM
Just a guess ...

if(ifSubmit.contentWindow) {
doc = ifSubmit.contentWindow.document;

chandu2708
06-03-2009, 08:52 AM
Hi,

Thx for the reply. now the form is getting submitted. but hidden parameters that i have under the form (the ones i created dynamically) are not available on server side. i mean if try to access these parameters on the server side im getting null? as you see i added the same form that i have in the result page to the hidden iframe, if i submit the main form even with dynamic parameters i can access those on server side. this happens only in IE7, FF works fine. any help would be appriceated.

Thank you,
bala.

adios
06-03-2009, 05:26 PM
Too many unidentified variables there to really see what's happening. This is interesting:

var ifText = document.getElementById(rootElID).innerHTML;

Could you post that html string so we can see what's going into the iframe doc?