Computer >> Computer tutorials >  >> Programming >> Javascript

Microdata API in HTML5


The HTML5 microdata standard includes both HTML markup (primarily for search engines) and a set of DOM functions (primarily for browsers).

You can include microdata markup in your web pages, and search engines that do not understand the microdata attributes will just ignore them. However, if you need to access or manipulate microdata through the DOM, you will need to check whether the browser supports the microdata DOM API.

If a browser supports the HTML5 microdata API, there will be a getItems() function on the global document object. If the browser doesn't support microdata, the getItems() function will be undefined.

function supports_microdata_api() {
   return !!document.getItems;
}