Skip to content

Instantly share code, notes, and snippets.

@konishi
Created November 13, 2012 13:01
Show Gist options
  • Save konishi/4065650 to your computer and use it in GitHub Desktop.
Save konishi/4065650 to your computer and use it in GitHub Desktop.
URLのタイトルを取得するスクリプト ref: http://qiita.com/items/45c852e2af3d6d8b0736
var checkUrl = "取得したいURL";
function getTitle(url,callback){
var xhr=new XMLHttpRequest()
xhr.onload = function() {
var title=this.responseXML.title||"no title"
callback(url,title)
}
xhr.open("GET", url ,true);
xhr.responseType="document";
xhr.send();
}
getTitle(checkUrl, function(url, title) {
console.log(title);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment