Maybe you all know about the issue GoogleChrome and Safari has with using navigatetoURL. It works only in IE. Thus I gathered the following code from a forum. The code is a javascript function place in the html file. Then there is another function in Flex, which is called when a button is clicked. Part of the code is here:
variables.pmsg1 = xml_langue.msg1;
variables.pmsg2 = xml_langue.msg2;
variables.pmsg3 = xml_langue.msg3;
variables.pmsg4 = xml_langue.msg4;
variables.ppaytomode = parentApp.PAYTOMODE;
var request:URLRequest = new URLRequest(dir_web);
request.data = variables;
request.method = "GET";
//navigateToURL(request,"_blank");
postXMLPageRequest(variables, request.toString(), '_blank'); // HERE I AM CALLING THE FLEX FUNCTION
THE FLEX FUNCTION BELOW:
public function postXMLPageRequest(data:Object, pageURL:String, window:String=null):void { if (ExternalInterface && ExternalInterface.available) ExternalInterface.call("postXMLPageRequest", pageURL, data.encode().toString(), window); }
THE JAVASCRIPT FUNCTION (found in html file) BELOW:
function postXMLPageRequest(url, xmlString, target, method) { method = method || "POST"; target = target || "_blank";
<%----------------------------------------------------------%> <%-- Create a form element with the specified attributes. --%> <%----------------------------------------------------------%> var form = document.createElement("form"); form.setAttribute("action", url); form.setAttribute("method", method); form.setAttribute("target", target); form.setAttribute("ENCTYPE", "text/plain"); form.setAttribute("style", "display: none");
<%--------------------------------------------------------------------%> <%-- Add the XML string as the value to a hidden input to the form. --%> <%--------------------------------------------------------------------%> var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", "' + xmlString); form.appendChild(hiddenField );
<%-----------------------------------------%> <%-- Add the form to the body, submit it --%> <%-- then remove the form from the body. --%> <%-----------------------------------------%> document.body.appendChild(form); form.submit(); document.body.removeChild(form); }
However nothing is being executed when I click the button which calls the postXMLPageRequest function> CAn somebody help me with this?
Thanks a lot.