...

View Full Version : Ajax differences



kuvera
01-06-2007, 06:37 PM
Hello, is there a site with a detailed list of browser dependency regarding Ajax?

Kor
01-07-2007, 08:42 AM
You don't need that. You must test only which kind of request object is recognized by the browser, the DOM compliant XMLHttpRequest (IE7, Moz, NS, Opera, Safari...) or the the ActiveX request object (IE5, IE6). To simplify:


if (window.XMLHttpRequest){
......
else if(window.ActiveXObject){
.....
}

Well the ActiveX object might have different arguments, depending on the Microsoft XML variant ('Microsoft.XMLHTTP', Msxml2.XMLHTTP) and the IceBrowser (on Java) still uses window.createRequest() method, so a little bit extended detecting code could look like:


var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}

A1ien51
01-07-2007, 03:38 PM
Kor,

The second script will force IE7 into ActiveX instead of the native, not good! Object detection should really be the only way to go.

Eric

Kor
01-07-2007, 10:00 PM
maybe. It was only my first thought.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum