onEndTag_(tagname)()

Replace (tagname) with the actual tag name. When an end tag with that tagname is encountered, This function is called after any other end tag programs assigned to the element. For example, use the function name onEndTag_textarea if you want the function to execute when a "textarea" end tag is encountered. (New v10.9912)

NOTE: Although most function names are case-sensitive, the (tagname) part of this function name is case-insensitive.

Example 1:

This examples generates a message that shows the heading text every time the "h1" heading tag is used.

You can also add functions for the other HTML heading elements as well ("h2", "h3", "h4", etc). For example, use a function named onEndTag_h2() to generate a message every time the "h2" heading element is used.

function onEndTag_h1() {
 Message(1, MSG_MESSAGE, 'h1 heading text: '+getValueString(33), getLocation(3,0));
}

Use the MessageEx() function for more advanced messages, like messages with a message ID and message category:

function onEndTag_h1() {
 MessageEx(5, 2017100300, MSG_MESSAGE, 'H1 Heading Text', 'h1 heading text: '+getValueString(33), getLocation(3,0));
}

Note: When a message category is used, the message is typically displayed in the Grouped tab in the Results Window.

Example 2:

This example generates error messages for missing meta tags.

Because the default configuration file sets variable names based on which meta tags are used, the variables can be used to check to see if there are any missing meta tags in the head section.

function onEndTag_head() {
 $metaname="dcterms.title"; checkMetaDataExists();
 $metaname="dcterms.subject"; checkMetaDataExists();
 $metaname="dcterms.language"; checkMetaDataExists();
}
 
// checks to make sure there's meta data for $metaname
function checkMetaDataExists() {
 $varname="meta"+toLower($metaname)+"used";
 if !isDefined($varname) { Message(1,MSG_ERROR,'Missing a "'+$metaname+'" meta tag.'); }
}

Example 3:

This example generates a message if the document's title is over 100 characters.

function onEndTag_title() {
 if getValueInt(41)>100 {
  MessageEx(5,2014092900,MSG_WARNING,$SEARCHENGINE,"This document's title is "+getValueInt(41)+' characters and may be too long.',getLocation(3));
 }
}