zjrJS Javascript Library

zjrJS.Doc.mbh() and mbn() - zjrJS Javascript Library

This information lives on a webpage hosted at the following web address: 'https://omegajunior.globat.com/code/zjrjs/'.

How to use zjrJS.Doc.mbh() ("meta by http-equib") and mbn() ("meta by name")

Declaration
zjrJS.Doc.mbh(String http-equiv);
zjrJS.Doc.mbn(String name);


Goal
To retrieve the value of the content attribute of all meta elements identified by the same http-equiv and name, respectively.

Typical usage
Your web pages' metas contain unique identifiers that help your scripts make the right choices, like which keywords to retrieve for a tag cloud, or which suggestions to load for a search box.

Member Type
Function.

Value Type
String: a comma-separated list of values containing the values of the content attributes of the matching HtmlMetaElements. If no match was found, the String is empty. If 1 match was found, any commas stem from the match' content.

Be careful when...
When you want to retrieve the description meta contents. The description often contains commas itself. You may think normal HTML pages sport only one description. Though a common occurrence, there is no restriction in the HTML recommendation that enforces such. As a matter of fact, a page can contain several descriptions in several languages.

Parameters
String http-equiv or name, respectively: anything valid as a String in HTML will do.

Dependencies
zjrJS.Doc.mbx(): the generic variation called by both mbh() and mbn().

Example
<script type="text/javascript" src="zjrJS.version.js" id="zjrJS"></script>
<script type="text/javascript">/* <![CDATA[ */
function goFetchSomeAdditionalData(pageType){
if(pageType){
zjrJS.Doc.lS("myDataFetcher.js?type=" + urlencode(pageType), "myDataFetcher", 30);
}
}

zjrJS.Doc.aE(window,"load",function(){
goFetchSomeAdditionalData(zjrJS.Doc.mbn("x-zjr-pagetype"));
});
/* ]]> */</script>


The above example is modelled after similar use in a client's intranet web site.

Download:

Download zjrJS’ latest stable build (20141202t2322) minified (7.1KB).

Download zjrJS’ latest stable build (20141202t2322) (11.9KB).

Clicky Analytics