Get the App
SLTechnology News&Howtos  ›  Development  › 

How to achieve Multi-browser compatibility with XMLHTTP

Shulou Source: shulou.com Published: 2022-06-03 05:41:11 11月17日 Update

This article is about how XMLHTTP achieves multi-browser compatibility. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The code is as follows:

Var xmlhttp=null

If (window.XMLHttpRequest) {

Xmlhttp = new XMLHttpRequest ()

}

If (! xmlhttp&&window.ActiveXObject)

{

Try

{

Xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP.5.0")

}

Catch (e)

{

Try

{

Xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP.4.0")

}

Catch (e)

{

Try

{

New ActiveXObject ("Msxml2.XMLHTTP")

}

Catch (e)

{

Try {new ActiveXObject ("Microsoft.XMLHTTP")} catch (e) {}

}

}

}

}

If (! xmlhttp) {alert ("XMLHTTP is not available. About to jump to a non-Ajax page.") ; location= "nonAjax.htm"}

Thank you for reading! This is the end of the article on "how to achieve multi-browser compatibility in XMLHTTP". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Compatibility browser browsing content more articles good practical code articles read knowledge pages references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB Apple Xiaomi Microsoft