09
Mar
Posted By: Ian on Mar 09, 2011 in JavaScript, JQuery, Snippets
Last modified on January 12th, 2013 at 3:09 pm,
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>');
});
</script>
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>');
</script>



Great script but can you tell me that how i can extract TITLE, DESCRIPTION of a URL? I mean how i can extract http://www.example.com TITLE, DESCRIPTION using this script.
Thankyou
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