Skip to content

Instantly share code, notes, and snippets.

@ngmaloney
Created June 27, 2011 21:07
Show Gist options
  • Save ngmaloney/1049839 to your computer and use it in GitHub Desktop.
Save ngmaloney/1049839 to your computer and use it in GitHub Desktop.
A Javascript function used to extract meta description from an HTML document.
/**
* Returns document meta description
*/
getMetaDescription = function() {
var metas = document.getElementsByTagName('meta');
for(var i in metas) {
if (typeof(metas[i].name) != 'undefined' && metas[i].name.toLowerCase() == "description") {
return encodeURIComponent(metas[i].content);
}
}
return '';
}
@ahmedam55
Copy link

Thank you for your time and effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment