Connecting Tech Pros Worldwide Help | Site Map

Modify Meta Tag with JavaScript

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 07:11 PM
Jim
Guest
 
Posts: n/a
Default Modify Meta Tag with JavaScript

Is there a way to modify a meta tag's content in javascript? Any
examples would be appreciated. Thanks


  #2  
Old July 23rd, 2005, 07:12 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.