This site is no longer active and is left here for archive purposes

Get the Page Title Description and Url

Posted By: Ian on Mar 09, 2011 in JavaScript, JQuery, Snippets
Last modified on January 12th, 2013 at 3:09 pm,

JQuery version:

<script type="text/javascript">
$(document).ready(function () {
var pageTitle = $(document).attr('title');
var pageHref = $(location).attr('href');
var pageDescription = $('meta[name=description]').attr("content");
$('#result').html('<a href="' + pageHref + '">' + pageTitle + '</a><br />' + pageDescription + 
'<br /><span class="green">' + pageHref + '</span>');

Try Me

Javascript Version:

<script type="text/javascript">
var a = (document.title);
var b = (document.location.href);
var c = document.getElementsByTagName('meta');
var description;
for (var x = 0, y = c.length; x < y; x++) {
    if (c[x].name.toLowerCase() == "description") {
        description = c[x];
document.write('<a href="' + b + '">' + a + '<\/a><br />' + description.content + '<br />');
document.write('<span id="green">' + b + '<\/span>');


Try MeDownload .rar

Download .zip


Did this help you? Please Let me know by commenting below even if it’s just to say “Thanks”

Discussion - 2 Comments

  • Rakib Rakib Jun 21, 2011 

    Great script but can you tell me that how i can extract TITLE, DESCRIPTION of a URL? I mean how i can extract TITLE, DESCRIPTION using this script.

    • admin admin Jun 21, 2011 

      Thank you for your question but in order to extract the TITLE and DESCRIPTION from a remote URL you will need another script like my Meta Tag and Title Grabber

About This Site

Dreams are built from lines of code well it's true!
If you can dream it you can usually code it.

I have learned so much from other people on the Internet and this site is for me to give back some of what i have learned and hope people can now learn from me.
Have fun and surf safely,

protected by copyscape duplicate content check


Powered by Banner Bar 125