Search code examples
javascriptjquerygettitle

How can I get the title of a webpage given the url (an external url) using JQuery/JS


I am a newbie, so excuse me if this is a silly question ..

So what I was trying is to get the title of a URL using JQuery/JS. I dont want to load the content of the url and then parse tags in it.

Let me be more clear, I have a set of urls, say 20 for which I want to display the titles .. the urls i am referring to are not the current urls, so I cant use js document.title ..

so i want to do something of the form SOMEFUNC.title(URL) and get its title. Is there any such function?


Solution

  • You can also get the title of any webpage using this API

    http://textance.herokuapp.com/title/

    $.ajax({
          url: "http://textance.herokuapp.com/title/www.bbc.co.uk",
          complete: function(data) {
            alert(data.responseText);
          }
    });