Created
November 13, 2012 13:01
-
-
Save konishi/4065650 to your computer and use it in GitHub Desktop.
URLのタイトルを取得するスクリプト ref: http://qiita.com/items/45c852e2af3d6d8b0736
This file contains 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
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