2018-07-26 01:00:21   Visit  1347

jQuery 获取指定url标题



function getTitleOfUrl(u, callback) {
    var url = \\\"jsapi/proxy.jsp?\\\" + u;
    $.ajax({
        url: url,
        complete: function (e) {
            var text = e.responseText;
            text = text.replace(/\\\\s*/g,\\\"\\\");
            var reg = /<title>(.*)\\\\<\\\\/title>/;
            window.b = e;
            title = text.match(reg)[1];
            callback&&callback(title,e)
        }
    })
}
var u = \\\"http://leechg.com\\\";
getTitleOfUrl(u, function(title,e){
    console.log(title)
})

©2017 Leechg.com