Is it possible to use JavaScript to change the meta-tags of the page?

TIMEX picture TIMEX · Apr 2, 2010 · Viewed 238.9k times · Source

If I put a div in the head and display:none, than use JavaScript to display it, will this work?

Edit:

I have stuff loaded in AJAX. And as my AJAX changes the "main" portion of the site, I want to change the meta-tags as well.

Answer

jayms picture jayms · Mar 17, 2016

Yes, it is.

E.g. to set the meta-description:

document.querySelector('meta[name="description"]').setAttribute("content", _desc);