hi.
i have spent the past week (i am afraid) trying to get
the below script for uploading files via a hidden iframe
to work.
i have narrowed down my problem to the possibility that
IE doesnt like the fact that the script is instantiating the
object type so many times (of course, tell me if i am wrong).
whatever the case, when i alert the outterHTML of the page,
the <iframetag is always empty (no files inside). I'd
really really apprecaite some help here...
i have enclose the problem block in comments below.
thanks.
pbd
<script type="text/javascript">
var IFrameObj; // our IFrame object
function callToServer(th eFormName) {
if (!document.crea teElement) {
return true
};
var IFrameDoc;
var URL = 'set_progress.a spx' + buildQueryStrin g(theFormName);
//FOR ERROR CHECKING - FULL RESPONSETEXT IN NEW WINDOW
//var doc = URL;
// doc=doc.replace (/</g, '<').replace (/\>/g, '>');
//childWin=window .open("", "childwin") ;
//childWin.docume nt.write("<pre> "+doc+"</pre>");
//childWin.docume nt.close();
if (!IFrameObj && document.create Element) { //1
// create the IFrame and assign a reference to the
// object to our global variable IFrameObj.
// this will only happen the first time
// callToServer() is called
try { //2
var tempIFrame=docu ment.createElem ent('iframe');
tempIFrame.setA ttribute('id',' RSIFrame');
tempIFrame.styl e.border='0px';
tempIFrame.styl e.width='0px';
tempIFrame.styl e.height='0px';
IFrameObj = document.body.a ppendChild(temp IFrame);
if (document.frame s) { //3
// this is for IE5 Mac, because it will only
// allow access to the document object
// of the IFrame if we access it through
// the document.frames array
IFrameObj = document.frames['RSIFrame'];
} // end 3
} // end 2
catch(exception ) { // 3
// This is for IE5 PC, which does not allow dynamic creation
// and manipulation of an iframe object. Instead, we'll fake
// it up by creating our own objects.
iframeHTML='\<i frame id="RSIFrame" style="';
iframeHTML+='bo rder:0px;';
iframeHTML+='wi dth:0px;';
iframeHTML+='he ight:0px;';
iframeHTML+='"> <\/iframe>';
document.body.i nnerHTML+=ifram eHTML;
debugger;
//!------------------------- PROBLEM BLOCK
----------------------------------------
IFrameObj = new Object();
IFrameObj.docum ent = new Object();
IFrameObj.docum ent.location = new Object();
IFrameObj.docum ent.location.if rame =
document.getEle mentById('RSIFr ame');
IFrameObj.docum ent.location.re place = function(locati on) { //4
this.iframe.src = location;
} // end 4
//!------------------------- PROBLEM BLOCK
----------------------------------------
} // end 3
} // end 2
if ((navigator.use rAgent.indexOf( 'Firefox') != -1) &&
(!IFrameObj.con tentDocument)) {
// we have to give Firefox 1.5 a fraction of a second
// to recognize the new IFrame
setTimeout('cal lToServer("'+th eFormName+'")', 50);
return false;
}
if (navigator.user Agent.indexOf(' Gecko') !=-1 &&
!IFrameObj.cont entDocument) {
// we have to give NS6 a fraction of a second
// to recognize the new IFrame
setTimeout('cal lToServer("'+th eFormName+'")', 10);
return false;
}
if (IFrameObj.cont entDocument) {
// For NS6
IFrameDoc = IFrameObj.conte ntDocument;
} else if (IFrameObj.cont entWindow) {
// For IE5.5 and IE6
IFrameDoc = IFrameObj.conte ntWindow.docume nt;
} else if (IFrameObj.docu ment) {
alert("IE5");
IFrameDoc = IFrameObj.docum ent;
} else {
return true;
}
//IFrameDoc.locat ion.replace=URL ;
IFrameDoc.locat ion.replace(URL );
return false;
}
function buildQueryStrin g(theFormName) {
var theDIV = document.getEle mentById('uploa dDIV');
var theInputs = theDIV.getEleme ntsByTagName('i nput');
var qs = '';
for (e=0;e<theInput s.length;e++) {
if (theInputs[e].name!='') {
qs+=(qs=='')?'? ':'&'
if (theInputs[e].value != ""){
qs+=theInputs[e].name+'='+escap e(theInputs[e].value)
}
}
}
return qs
}
</script>
Comment