Connecting Tech Pros Worldwide Help | Site Map

Modify Meta Tag with JavaScript

Jim
Guest
 
Posts: n/a
#1: Jul 23 '05
Is there a way to modify a meta tag's content in javascript? Any
examples would be appreciated. Thanks

Martin Honnen
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Modify Meta Tag with JavaScript




Jim wrote:
[color=blue]
> Is there a way to modify a meta tag's content in javascript?[/color]

Browsers that support getElementsByTagName will allow you access to
elements by the tag name (e.g. 'meta') and then the HTMLMetaElement
object implements
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-37041454>

var meta;
if (document.getElementsByTagName) {
meta = document.getElementsByTagName('meta')[0];
if (meta) {
meta.name = 'Author';
meta.content = 'Kibo';
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread