Javascript current URL meta description


Blog News | Dulisha | Tuesday, 15 April 2014 18:28

I have been done some research. This example will show you how you can get from current URL title and description.










We are going to reach first trick using jQuery

<script type="text/javascript">
$(document).ready(function () {
var pageDescription = $('meta[name=description]').attr("content");
$('#result').html(pageDescription);
});
</script>

And here it is with Javascript

<script type="text/javascript">
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(description.content);
</script>