Jump to content

Find meta variable with javascript


Recommended Posts

  • Administrators

I was doing a bit of work on my blog that is hosted on a OSX server, when i came to the point that needed to import a meta variable in javascript.. so i made this little function...


function getMeta(varname) {
var metas = document.getElementsByTagName('META');
var i;
for (i = 0; i < metas.length; i++)
if (metas[i].getAttribute('NAME') == varname)
var GMresult = metas[i].getAttribute('CONTENT');
return GMresult;


You can test it by doing:


var result = getMeta("Content-Type");


... It should popup a javascript alert with the content of Content-Type

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
  • Create New...