Menu

#2 ideas to get multi browser functionality

open
nobody
None
5
2007-10-31
2007-10-31
jpieper
No

Do not check for IE and !IE. Check for available techniques to use AJAX.

Check for XMLHttpRequest
Check for ActiveXObject incl. MSXML.XMLHTTP
Check for SOAPCall
[see below @ getSupported()]

If you check for these three techniques instead of checking IE or !IE, GLM-AJAX will be able to be used with IE6/7, FF1/2, Opera and Safari.

And please test the onReadyStateChange() for Opera. I don´t think this ever worked correctly.
[see onReadyStateChange() changes]

onReadyStateChange() for Opera:
----- SNIPPET START -----------------------------------------------------------
if(xmlHttp.callbackFunction &&
(!document.all || (navigator.appName.indexOf('Opera') >= 0)))
{
xmlHttp.callbackFunction(
xmlHttp.responseXML.getElementsByTagName('return')[0].textContent
);
}
else
{
/* ... */
}
----- SNIPPET END -------------------------------------------------------------

new method getSupported()
----- SNIPPET START -----------------------------------------------------------
function AJAX
{
/* ... */

// method to get supported techniques
this.getSupported = function()
{
var XHR = (window.XMLHttpRequest != undefined);
var SOAP = (window.SOAPCall != undefined);
var MSXML = false;

try {
new ActiveXObject('MSXML2.XMLHTTP');
MSXML = true;
} catch(ex) {}

return {
'xhr' : XHR,
'soap' : SOAP,
'msxml' : MSXML
};
} // end getSupported

/* ... */
}
----- SNIPPET END -------------------------------------------------------------

changes in callService()
----- SNIPPET START -----------------------------------------------------------

OLD: var IE = (navigator.appName.indexOf("Microsoft") >= 0);
if (IE) { /* ... */ }

NEW: var supported = this.getSupported();
if(supported['xhr'] || supported['msxml']) { /* ... */ }

----- SNIPPET END -------------------------------------------------------------

Please do not think this is an perfect solution. It is only tested in small test applications and only one medium size application with success.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.