mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
31 lines
917 B
JavaScript
31 lines
917 B
JavaScript
// browser shim for xmlhttprequest module
|
|
var hasCORS = require('has-cors');
|
|
|
|
module.exports = function(opts) {
|
|
var xdomain = opts.xdomain;
|
|
// scheme must be same when usign XDomainRequest
|
|
// http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
|
|
var xscheme = opts.xscheme;
|
|
|
|
// Use XDomainRequest for IE8 because loading bar keeps flashing when using jsonp-polling
|
|
// https://github.com/yujiosaka/socke.io-ie8-loading-example
|
|
try {
|
|
if ('undefined' != typeof XDomainRequest && !xscheme) {
|
|
return new XDomainRequest();
|
|
}
|
|
} catch (e) { }
|
|
|
|
// 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) { }
|
|
}
|
|
}
|