Skip to content

Instantly share code, notes, and snippets.

@AshKyd
Created December 6, 2013 14:47
Show Gist options
  • Save AshKyd/7825918 to your computer and use it in GitHub Desktop.
Save AshKyd/7825918 to your computer and use it in GitHub Desktop.
Get the content type for a certain URL.
function getContentType(url,callback){
var oReq = new XMLHttpRequest();
oReq.onreadystatechange = function(){
if(this.readyState == this.DONE){
callback(this.getResponseHeader("content-type"));
}
};
oReq.open("head", url, true);
oReq.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment