Skip to content

Instantly share code, notes, and snippets.

@wangpin34
Created August 17, 2016 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangpin34/40567d7eb72ea7d2426ad5804b3c418b to your computer and use it in GitHub Desktop.
Save wangpin34/40567d7eb72ea7d2426ad5804b3c418b to your computer and use it in GitHub Desktop.
fetch meta info contains http-equiv, name
function fetchMetas() {
var metas = [].slice.call(document.getElementsByTagName('meta')).map(function(e) {
var data = {}
var key = ''
var value = ''
if(e.getAttribute('name')){
data.name = e.getAttribute('name')
data.content = e.getAttribute('content')
return data
}else if(e.getAttribute('http-equiv')){
data['http-equiv'] = e.getAttribute('http-equiv');
data.content = e.getAttribute('content')
return data
}
return null;
}).filter(function(e){
return !!e;
})
return metas
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment