onStartTag_(tagname)()
Replace (tagname) with the actual tag name. When a start tag with the tagname is encountered, this function is executed after any other start tag programs assigned to the element. For example, use the function name onStartTag_textarea if you want the function to execute when a "textarea" start tag is encountered. (New v10.9912)
NOTE: Although most function names are case sensitive, the (tagname) part of this function name is case-insensitive.
function onStartTag_h1() {
$h1tagcounter++;
Message(1,MSG_MESSAGE,'This is "h1" start tag #'+toString($h1tagcounter));
}
This example checks to see if a meta tag has a name of "pwgsc.contact.email", and if so, then it makes sure that the content is a valid email address (syntax check only). If it's not, then it generates an error message.
function onStartTag_meta() {
if hasAttWithStringValue("name","pwgsc.contact.email") {
if hasAtt("content") {
if !checkStringEx(0,39,getAttValueEx("content",12)) {
Message(1,MSG_ERROR,'Bad email address: '+$checkstringex39details,getAttValueLocation("content"));
}
}
}
}
This example checks that the content of certain meta data is meaningful (it's not empty or only whitespace).
function onStartTag_meta() {
if hasAtt("name") {
$namevalue=getAttValue("name");
if $namevalue=="dcterms.title" { checkMetaDataNonWhitespace(); }
else { if $namevalue=="dcterms.subject" { checkMetaDataNonWhitespace(); }
else { if $namevalue=="dcterms.language" { checkMetaDataNonWhitespace(); }
else { if $namevalue=="dcterms.creator" { checkMetaDataNonWhitespace(); }
}}} // one right brace for each else
}
}
function checkMetaDataNonWhitespace() {
if hasAtt("content") {
$contentindex=getAttIndex("content");
if checkStringEx(0,33,getAttValue($contentindex)) {
Message(1,MSG_ERROR,'The "content" value is empty or contains only whitespace characters. Meaningful text is required.',getAttValueLocation($contentindex));
}
}
}