Last active
February 17, 2017 06:52
-
-
Save kyeljmd/e577ed5b58d8d70855a9b0bfff6cc398 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var isCorsEnabled = function(tag) { | |
var corsEnabled; | |
var target = $(tag)[0]; | |
var currentSrcUrl = target.src.split("_t=").join("_t=1"); // add a leading 1 to the ts | |
$.ajax({ | |
url: currentSrcUrl, | |
async: false | |
}) | |
.done(function() { | |
// things worked out, we can add the CORS attribute and reset the source | |
target.crossOrigin = "anonymous"; | |
target.src = currentSrcUrl; | |
corsEnabled = true; | |
}) | |
.fail(function() { | |
corsEnabled = false; | |
}); | |
return corsEnabled; | |
} | |
window.isCorsEnabled = isCorsEnabled | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment