是否可以使用 JavaScript 来更改页面的元标记? [英] Is it possible to use JavaScript to change the meta-tags of the page?
本文介绍了是否可以使用 JavaScript 来更改页面的元标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在 head 中放一个 div 并显示:none,而不是使用 JavaScript 来显示它,这行得通吗?
If I put a div in the head and display:none, than use JavaScript to display it, will this work?
我在 AJAX 中加载了一些东西.当我的 AJAX 更改网站的主要"部分时,我也想更改元标记.
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.
推荐答案
是的.
例如设置元描述:
document.querySelector('meta[name="description"]').setAttribute("content", _desc);
这篇关于是否可以使用 JavaScript 来更改页面的元标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文