Get an XMLHTTP object in a variety of browser environments

xiaoxiao2021-03-19  178

Get an XMLHTTP object in a variety of browser environments

In Internet Explorer, you create the object using new ActiveXObject ( "Msxml2.XMLHTTP") or new ActiveXObject ( "Microsoft.XMLHTTP") depending on the version of MSXML installed. In Mozilla and Safari (and likely in future UA's that support it) You use new xmlhttpRequest () IceBrowser Uses Yet Another Method The window.createrequest () Method.

function GetXmlHttp () {var xmlhttp = false; try {xmlhttp = new ActiveXObject ( "Msxml2.XMLHTTP");} catch (e) {try {xmlhttp = new ActiveXObject ( "Microsoft.XMLHTTP");} catch (E) { xmlhttp = false;}} 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;}} Return XMLHTTP;}

转载请注明原文地址:https://www.9cbs.com/read-130159.html

New Post(0)