Created
June 27, 2011 21:07
-
-
Save ngmaloney/1049839 to your computer and use it in GitHub Desktop.
A Javascript function used to extract meta description from an HTML document.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your time and effort