Processing
 

Detect if browser does not support XMLHttpRequest with full CORS support

01/09/2016 19:44#1

Justin

Member

Joined at: 11 months ago

Post: 197

Thank: 0

Thanked: 0

How do I check if a browser supports the native JavaScript XMLHttpRequest object with CORS? I am testing in IE 8 which as I understood only supports XDomainRequest, however doing the following in IE 8:

typeof window.XMLHttpRequest "object" 

I would have thought that would be undefined. Basically how can I detect if a browser supports the full XMLHttpRequest with CORS support?

Should I do the inverse?

if(type window.XDomainRequest === 'object') {     // Assume the browser does not support XMLHttpRequest with CORS } 
01/09/2016 20:00Top#2

fred_

Member

Joined at: 5 months ago

Post: 1

Thank: 0

Thanked: 0

I use this, 1 means XMLHttpRequest support cors, 2 means cors is supported via XDomainRequest, 0 means no CORS support

var  corsSupportLevel = null;     function supportsCorsInternal() {                  if (corsSupportLevel !== null) return corsSupportLevel;                  var xhr = new XMLHttpRequest();                 if ("withCredentials" in xhr) {                     // Supports CORS                     corsSupportLevel = 1;                 } else if (typeof XDomainRequest !== "undefined") {                     // IE                     corsSupportLevel = 2;                 } else {                     corsSupportLevel = 0;                 }                 return corsSupportLevel;             } 
Similar articles

IE9 dosen't support my Button Tag

5 months ago - Reply: 0 - Views: 18

SSRS 2016 Web protal in IE8

5 months ago - Reply: 0 - Views: 17

how to handle @keyframes not supported by ie9?

5 months ago - Reply: 0 - Views: 5

Detect Windows XP in Firefox with JS

6 months ago - Reply: 1 - Views: 47

IE8 Not showing divs with floats

6 months ago - Reply: 2 - Views: 131

Including ECMA 5 script in IE8

6 months ago - Reply: 1 - Views: 98

XDomainRequest does not work in ie8 & ie9

6 months ago - Reply: 0 - Views: 11

How to minify angular.js?

6 months ago - Reply: 1 - Views: 32

VBA and IE8 - scrape text buried in table

6 months ago - Reply: 1 - Views: 39

Detect http satus IE10

6 months ago - Reply: 0 - Views: 8

how to compress angular.js?

6 months ago - Reply: 0 - Views: 4

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re