mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
20 lines
432 B
JavaScript
20 lines
432 B
JavaScript
// browser shim for xmlhttprequest module
|
|
var hasCORS = require('has-cors');
|
|
|
|
module.exports = function(opts) {
|
|
var xdomain = opts.xdomain;
|
|
|
|
// XMLHttpRequest can be disabled on IE
|
|
try {
|
|
if ('undefined' != typeof XMLHttpRequest && (!xdomain || hasCORS)) {
|
|
return new XMLHttpRequest();
|
|
}
|
|
} catch (e) { }
|
|
|
|
if (!xdomain) {
|
|
try {
|
|
return new ActiveXObject('Microsoft.XMLHTTP');
|
|
} catch(e) { }
|
|
}
|
|
}
|