ltm rule command HTML tagΒΆ

iRule(1)					  BIG-IP TMSH Manual					     iRule(1)

HTML::tag
       Query and update the HTML tag.

SYNOPSIS
       HTML::tag ((append STRING) | name | (prepend STRING) | remove)

   DESCRIPTION
       HTML::tag append  Insert a string after the closing delimiter of the HTML tag; when multiple appends are
       issued, the inserted strings are ordered according to the sequence of the append commands as they are issued
       for the given tag.

       HTML::tag name Return HTML tag name, where name is the HTML element if the tag is a start tag, and if the tag
       is an end tag, tag name returns "/" + the HTML element.

       HTML::tag prepend  Insert a string before the opening delimiter of the HTML tag; when multiple prepends
       are issued, the inserted strings are ordered according to the sequence of the prepend commands as they are
       issued for the given tag.

       HTML::tag remove Remove the HTML tag.

       HTML::tag attribute (count | (exists ATTR) | (insert ATTR VALUE) | names | (remove ATTR) | (replace ATTR
       VALUE) | (value ATTR) | ATTR)

   DESCRIPTION
       HTML::tag attribute  HTML::tag attribute value  Return the value of the attribute under this HTML
       tag.

       HTML::tag attribute count Return the number of attributes in this HTML tag.

       HTML::tag attribute exists  Return true if the HTML tag has the attribute identified by 

       HTML::tag attribute insert   Insert a string of "=" pair at the end of the
       attributes, before the closing delimiter of the tag.

       HTML::tag attribute names Return the names of all attributes in this HTML tag.

       HTML::tag attribute remove  Remove the attribute identified by  in this HTML tag.

       HTML::tag attribute replace   Replace the existing value of the attribute, identified by ,
       with .

DESCRIPTION
       Queries, removes and changes attribute/value pairs of this HTML tag.

RETURN VALUE
       "HTML::tag name" returns tag name.  "HTML::tag attribute value " returns the value of the attribute
       under this HTML tag.  "HTML::tag attribute count" returns the number of attributes in this HTML tag.
       "HTML::tag attribute exists " returns true if the HTML tag has the attribute identified by .

VALID DURING
       HTML_TAG_MATCHED

EXAMPLES
	Auto-submit Stock Symbol Lookup on Yahoo-Finance.

	The iRule enables HTML on the root path and disables HTML everywhere else. The HTML iRule scans the HTML document as it streams from the backend server and raises HTML_TAG_MATCHED event when seeing it encounters the FORM start tag and the FORM end tag. Specifically, the iRule looks for the form that has an attribute ID with a value "quote". Once this form is found, the iRules remembers it and injects a piece of Javascript after the first FORM end tag.

	when HTTP_REQUEST {
	    set uri [HTTP::uri]
	    HTTP::header replace "Host" "finance.yahoo.com"
	}

	when HTTP_RESPONSE {
	    if { $uri equals "/" } {
		HTML::enable
	    } else {
		HTML::disable
	    }
	}

	when HTML_TAG_MATCHED {
	    log local0. "element = [HTML::tag name]"
	    log local0. "attribute id = [HTML::tag attribute id]"
	    switch [HTML::tag name] {
		"form" {
		    if { [HTML::tag attribute "id"] equals "quote" } {
			set inject_js 1
		    }
		}

		"/form" {
		    if { [info exists inject_js] && $inject_js == 1 } {
			unset inject_js
			HTML::tag append ""
			HTML::tag append "function submitForm() {"
			HTML::tag append "  document.quote.s.value='FFIV';"
			HTML::tag append "  document.quote.submit();"
			HTML::tag append "}"
			HTML::tag append "setTimeout('submitForm()', 5000);"
			HTML::tag append ""
		    }
		}
	    }
	}

HINTS
SEE ALSO
CHANGE LOG
       @BIGIP-11.0.0
	   --First introduced the command.  @BIGIP-11.4.0 --Add "HTML::tag attribute count" --Add "HTML::tag
       attribute remove "

BIG-IP						      2020-06-23					     iRule(1)