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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...