Jump to content

Find meta variable with javascript


Leon

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...

 

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

 

You can test it by doing:

 

<script>
var result = getMeta("Content-Type");
alert(result);
</script>

 

... 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...