mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-16 23:03:13 +03:00
Use ActiveX on IE when requesting a file: URL with ajax.
This commit is contained in:
parent
47ae094675
commit
3b4dca329d
@ -1741,35 +1741,35 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
return match[1].toLowerCase();
|
return match[1].toLowerCase();
|
||||||
},
|
},
|
||||||
|
|
||||||
createAjaxRequest: function(){
|
/**
|
||||||
var request;
|
* Create an XHR object
|
||||||
|
* @param {type} [local] If set to true, the XHR will be file: protocol
|
||||||
|
* compatible if possible (but may raise a warning in the browser).
|
||||||
|
* @returns {XMLHttpRequest}
|
||||||
|
*/
|
||||||
|
createAjaxRequest: function( local ) {
|
||||||
|
if ( window.ActiveXObject ) {
|
||||||
if ( window.XMLHttpRequest ) {
|
if ( window.XMLHttpRequest ) {
|
||||||
|
$.createAjaxRequest = function( local ) {
|
||||||
|
if ( local ) {
|
||||||
|
/* global ActiveXObject:true */
|
||||||
|
return new ActiveXObject( "Microsoft.XMLHTTP" );
|
||||||
|
}
|
||||||
|
return new XMLHttpRequest();
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
$.createAjaxRequest = function() {
|
||||||
|
return new ActiveXObject( "Microsoft.XMLHTTP" );
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if ( window.XMLHttpRequest ) {
|
||||||
$.createAjaxRequest = function() {
|
$.createAjaxRequest = function() {
|
||||||
return new XMLHttpRequest();
|
return new XMLHttpRequest();
|
||||||
};
|
};
|
||||||
request = new XMLHttpRequest();
|
} else {
|
||||||
} else if ( window.ActiveXObject ) {
|
|
||||||
/*jshint loopfunc:true*/
|
|
||||||
/* global ActiveXObject:true */
|
|
||||||
for ( var i = 0; i < ACTIVEX.length; i++ ) {
|
|
||||||
try {
|
|
||||||
request = new ActiveXObject( ACTIVEX[ i ] );
|
|
||||||
$.createAjaxRequest = function( ){
|
|
||||||
return new ActiveXObject( ACTIVEX[ i ] );
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
} catch (e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !request ) {
|
|
||||||
throw new Error( "Browser doesn't support XMLHttpRequest." );
|
throw new Error( "Browser doesn't support XMLHttpRequest." );
|
||||||
}
|
}
|
||||||
|
return $.createAjaxRequest( local );
|
||||||
return request;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -1782,7 +1782,8 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
makeAjaxRequest: function( url, onSuccess, onError ) {
|
makeAjaxRequest: function( url, onSuccess, onError ) {
|
||||||
var request = $.createAjaxRequest();
|
var protocol = $.getUrlProtocol( url );
|
||||||
|
var request = $.createAjaxRequest( protocol === "file:" );
|
||||||
|
|
||||||
if ( !$.isFunction( onSuccess ) ) {
|
if ( !$.isFunction( onSuccess ) ) {
|
||||||
throw new Error( "makeAjaxRequest requires a success callback" );
|
throw new Error( "makeAjaxRequest requires a success callback" );
|
||||||
@ -1793,7 +1794,6 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
if ( request.readyState == 4 ) {
|
if ( request.readyState == 4 ) {
|
||||||
request.onreadystatechange = function(){};
|
request.onreadystatechange = function(){};
|
||||||
|
|
||||||
var protocol = $.getUrlProtocol( url );
|
|
||||||
var successStatus =
|
var successStatus =
|
||||||
protocol === "http:" || protocol === "https:" ? 200 : 0;
|
protocol === "http:" || protocol === "https:" ? 200 : 0;
|
||||||
if ( request.status === successStatus ) {
|
if ( request.status === successStatus ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user