Modify Meta Tag with JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim

    #1

    Modify Meta Tag with JavaScript

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

  • Martin Honnen

    #2
    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 getElementsByTa gName 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.getEl ementsByTagName ) {
    meta = document.getEle mentsByTagName( 'meta')[0];
    if (meta) {
    meta.name = 'Author';
    meta.content = 'Kibo';
    }
    }

    --

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

    Comment

    Working...