atrejo78
atrejo78

Reputation: 1

How do I get the information from a meta tag with Dojo?

I am new to dojo and am trying to get the information from a meta tag that looks like this:

<meta content="Page101" scheme="SubjectTaxonomy" name="DC.Subject">

How do I get the "Page101" information?

Upvotes: 0

Views: 398

Answers (1)

Default
Default

Reputation: 16488

You can do this with the dojo/query module or the global dojo.query method. To get all meta tags and loop through them extracting the content you can do:

dojo.query('meta').forEach(function(metaTag){

  var content = metaTag.content;
  // Do something with the content.

});

Or if you are looking for a specific meta tag with content="Page101", you can restrict the selector like so:

dojo.query('meta[content="Page101"]')

This will return a NodeList with meta tags that match the desired content and you can do whatever you need to with them (probably only one).

Upvotes: 2

Related Questions