I have a problem with submitting a form to a PHP page through a
dynamically created IFRAME in IE7. This code works fine in Firefox.
However, IE7 submits an empty form--the correct PHP page is called, but
no form variables are passed to the page.
Here's the client-side code:
//Create or reuse an IFRAME to submit data to a specified page.
//commandToken: A string that tells the page what to do.
//data: Data that the page will work with.
//callbackFunctio nName: Name of javascript function to call when the
page returns.
//userID: ID of user.
//url: Page to which form will be submitted.
//iFrame: Name or reference of IFRAME through which the form data will
be submitted.
GenericWindow.p rototype.execut eServerRequest2 = function(comman dToken,
data, callbackFunctio nName, userID, url, iFrame)
{
var theIFRAME = null;
//If the specified IFRAME is a string then create the new IFRAME
element.
if(iFrame.lengt h)
{
theIFRAME = this.createData ExchangeIFrame2 (iFrame);
}
else
{
theIFRAME = iFrame;
}
if(callbackFunc tionName != null)
{
if(!url)
{
url = serverURL;
}
else
{
url = serverURLBase + url;
}
var htmlString = "<html><bod y onLoad=''>";
htmlString += '<form action="' + url + '" id="submitForm "
name="submitFor m" method="post">' ;
htmlString +='<input type="hidden" id="USERID" name="USERID" value="'
+ userID + '">';
htmlString +='<input type="hidden" id="DATA" name="DATA" value="' +
data + '">';
htmlString +='<input type="hidden" id="COMMAND" name="COMMAND"
value="' + commandToken + '">';
htmlString +='<input type="hidden" id="CALLBACK" name="CALLBACK"
value="window.p arent.bbsRender er.getWindow(&q uot;' + this._windowNam e +
'").' + callbackFunctio nName + '()">';
htmlString +='<input type="hidden" id="AUTHENTICAT ION_TOKEN"
name="AUTHENTIC ATION_TOKEN" value="' +
document.getEle mentById("AUTHO RIZATION_TOKEN" ).value + '">';
htmlString +='</form>';
htmlString +='</body></html>';
this.logCommand (commandToken, htmlString);
if(theIFRAME.co ntentDocument)
{
//For Mozilla and similar browsers.
theIFRAME.conte ntDocument.writ e(htmlString);
theIFRAME.conte ntDocument.getE lementById("sub mitForm").submi t();
}
else if(theIFRAME.do cument)
{
//For IE and similar browsers.
document.frames[theIFRAME.id].document.write (htmlString);
document.frames[theIFRAME.id].document.forms[0].submit();
}
}
return theIFRAME;
}
/*Creates the IFRAME used to communicate between the window and the
server.
If the IFRAME already exists, then it will be reused.*/
GenericWindow.p rototype.create DataExchangeIFr ame2 = function(iFrame ID)
{
var iFrame = document.getEle mentById(iFrame ID);
if(iFrame != null)
{
return iFrame;
}
else
{
iFrame = document.create Element("IFRAME ");
if(iFrameID == null)
{
iFrame.id = this._windowNam e + "_DataExchangeI Frame_" +
this._dataExcha ngeIFrameList.l ength;
}
else
{
iFrame.id = iFrameID;
}
this._windowFra me.appendChild( iFrame);
this._dataExcha ngeIFrameList[this._dataExcha ngeIFrameList.l ength] =
iFrame;
iFrame.src = "blank.html ";
return iFrame;
}
}
Here's the server-side code:
$userID = $_POST['USERID']; //Calling process's user ID. The value
must be numeric and not null.
$data = $_POST['DATA']; //Calling process's data.
$callback = $_POST['CALLBACK']; //Calling process's callback
information.
$commandToken = $_POST['COMMAND']; //Calling process's command token.
This value is required.
$authentication Token = $_POST['AUTHENTICATION _TOKEN']; //Calling
process's authentication token, used to verify sessions.
Result of a call in Firefox (I used PHPINFO() to dump the request and
post variables):
_REQUEST["USERID"] null
_REQUEST["DATA"] <GET_ROOM_DESCR IPTION roomID=\'2\' userID=\'0\'/>
_REQUEST["COMMAND"] GET_ROOM_DESCRI PTION
_REQUEST["CALLBACK"] window.parent.b bsRenderer.getW indow(\"LoginWi ndow\").handleG etDataResponse( )
_REQUEST["AUTHENTICATION _TOKEN"] no value
_POST["USERID"] null
_POST["DATA"] <GET_ROOM_DESCR IPTION roomID=\'2\' userID=\'0\'/>
_POST["COMMAND"] GET_ROOM_DESCRI PTION
_POST["CALLBACK"] window.parent.b bsRenderer.getW indow(\"LoginWi ndow\").handleG etDataResponse( )
_POST["AUTHENTICATION _TOKEN"] no value
The same call with the same data values produces no request or post
variables from IE.
Any help would be appreciated!
dynamically created IFRAME in IE7. This code works fine in Firefox.
However, IE7 submits an empty form--the correct PHP page is called, but
no form variables are passed to the page.
Here's the client-side code:
//Create or reuse an IFRAME to submit data to a specified page.
//commandToken: A string that tells the page what to do.
//data: Data that the page will work with.
//callbackFunctio nName: Name of javascript function to call when the
page returns.
//userID: ID of user.
//url: Page to which form will be submitted.
//iFrame: Name or reference of IFRAME through which the form data will
be submitted.
GenericWindow.p rototype.execut eServerRequest2 = function(comman dToken,
data, callbackFunctio nName, userID, url, iFrame)
{
var theIFRAME = null;
//If the specified IFRAME is a string then create the new IFRAME
element.
if(iFrame.lengt h)
{
theIFRAME = this.createData ExchangeIFrame2 (iFrame);
}
else
{
theIFRAME = iFrame;
}
if(callbackFunc tionName != null)
{
if(!url)
{
url = serverURL;
}
else
{
url = serverURLBase + url;
}
var htmlString = "<html><bod y onLoad=''>";
htmlString += '<form action="' + url + '" id="submitForm "
name="submitFor m" method="post">' ;
htmlString +='<input type="hidden" id="USERID" name="USERID" value="'
+ userID + '">';
htmlString +='<input type="hidden" id="DATA" name="DATA" value="' +
data + '">';
htmlString +='<input type="hidden" id="COMMAND" name="COMMAND"
value="' + commandToken + '">';
htmlString +='<input type="hidden" id="CALLBACK" name="CALLBACK"
value="window.p arent.bbsRender er.getWindow(&q uot;' + this._windowNam e +
'").' + callbackFunctio nName + '()">';
htmlString +='<input type="hidden" id="AUTHENTICAT ION_TOKEN"
name="AUTHENTIC ATION_TOKEN" value="' +
document.getEle mentById("AUTHO RIZATION_TOKEN" ).value + '">';
htmlString +='</form>';
htmlString +='</body></html>';
this.logCommand (commandToken, htmlString);
if(theIFRAME.co ntentDocument)
{
//For Mozilla and similar browsers.
theIFRAME.conte ntDocument.writ e(htmlString);
theIFRAME.conte ntDocument.getE lementById("sub mitForm").submi t();
}
else if(theIFRAME.do cument)
{
//For IE and similar browsers.
document.frames[theIFRAME.id].document.write (htmlString);
document.frames[theIFRAME.id].document.forms[0].submit();
}
}
return theIFRAME;
}
/*Creates the IFRAME used to communicate between the window and the
server.
If the IFRAME already exists, then it will be reused.*/
GenericWindow.p rototype.create DataExchangeIFr ame2 = function(iFrame ID)
{
var iFrame = document.getEle mentById(iFrame ID);
if(iFrame != null)
{
return iFrame;
}
else
{
iFrame = document.create Element("IFRAME ");
if(iFrameID == null)
{
iFrame.id = this._windowNam e + "_DataExchangeI Frame_" +
this._dataExcha ngeIFrameList.l ength;
}
else
{
iFrame.id = iFrameID;
}
this._windowFra me.appendChild( iFrame);
this._dataExcha ngeIFrameList[this._dataExcha ngeIFrameList.l ength] =
iFrame;
iFrame.src = "blank.html ";
return iFrame;
}
}
Here's the server-side code:
$userID = $_POST['USERID']; //Calling process's user ID. The value
must be numeric and not null.
$data = $_POST['DATA']; //Calling process's data.
$callback = $_POST['CALLBACK']; //Calling process's callback
information.
$commandToken = $_POST['COMMAND']; //Calling process's command token.
This value is required.
$authentication Token = $_POST['AUTHENTICATION _TOKEN']; //Calling
process's authentication token, used to verify sessions.
Result of a call in Firefox (I used PHPINFO() to dump the request and
post variables):
_REQUEST["USERID"] null
_REQUEST["DATA"] <GET_ROOM_DESCR IPTION roomID=\'2\' userID=\'0\'/>
_REQUEST["COMMAND"] GET_ROOM_DESCRI PTION
_REQUEST["CALLBACK"] window.parent.b bsRenderer.getW indow(\"LoginWi ndow\").handleG etDataResponse( )
_REQUEST["AUTHENTICATION _TOKEN"] no value
_POST["USERID"] null
_POST["DATA"] <GET_ROOM_DESCR IPTION roomID=\'2\' userID=\'0\'/>
_POST["COMMAND"] GET_ROOM_DESCRI PTION
_POST["CALLBACK"] window.parent.b bsRenderer.getW indow(\"LoginWi ndow\").handleG etDataResponse( )
_POST["AUTHENTICATION _TOKEN"] no value
The same call with the same data values produces no request or post
variables from IE.
Any help would be appreciated!
Comment