Skip to main content
Inspiring
May 18, 2007
Answered

DOM meta tags

  • May 18, 2007
  • 1 reply
  • 340 views
Hi there!

I'm writing an extension for DW8 that retrieves the contents of a meta tag from the current XHTML document:

<meta name="SKU_Condition" content="some_name" />

So I've got the following from the Extending DW help and the API ref:

var dom = dw.getDocumentDOM(); //get the dom of the current document
var skuCondMeta = dom.getElementsByTagName(???);

I see that the getElements function returns a list of child tags for a given tag type like DIV, IMG, etc.

Where do I go from here?

-Scott

This topic has been closed for replies.
Correct answer srowe3
Okay, here's the solution:

var dom = dw.getDocumentDOM(); //get the dom of the current document
var skuCondMeta = dom.getElementsByTagName("meta");
for ( counter = 0; counter < skuCondMeta.length; counter++)
{
if (skuCondMeta[counter].name == "some_name")
alert(skuCondMeta[counter].content);
}

1 reply

srowe3AuthorCorrect answer
Inspiring
May 18, 2007
Okay, here's the solution:

var dom = dw.getDocumentDOM(); //get the dom of the current document
var skuCondMeta = dom.getElementsByTagName("meta");
for ( counter = 0; counter < skuCondMeta.length; counter++)
{
if (skuCondMeta[counter].name == "some_name")
alert(skuCondMeta[counter].content);
}