HTML::tag attribute

Description

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

Syntax

HTML::tag attribute [value] <name>
HTML::tag attribute count
HTML::tag attribute exists <name>
HTML::tag attribute insert <name> <value>
HTML::tag attribute names
HTML::tag attribute remove <name>
HTML::tag attribute replace <name> <value>

HTML::tag attribute value <name>

  • Return the value of the attribute under this HTML tag.
  • Introduced: BIGIP-11.0.0

HTML::tag attribute count

  • Return the number of attributes in this HTML tag.
  • Introduced: BIGIP-11.4.0

HTML::tag attribute exists <name>

  • Return true if the HTML tag has the attribute identified by <name>
  • Introduced: BIGIP-11.0.0

HTML::tag attribute insert <name> <value>

  • Insert a string of “<name>=<value>” pair at the end of the attributes, before the closing delimiter of the tag.
  • Introduced: BIGIP-11.0.0

HTML::tag attribute names

  • Return the names of all attributes in this HTML tag.
  • Introduced: BIGIP-11.4.0

HTML::tag attribute remove <name>

  • Remove the attribute identified by <name> in this HTML tag.
  • Introduced: BIGIP-11.4.0

HTML::tag attribute replace <name> <value>

  • Replace the existing value of the attribute, identified by <name>, with <value>.
  • Introduced: BIGIP-11.0.0

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 "<scr"
    
    HTML::tag append "ipt>"
    
    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 "</script>"
    
    }
    
    }
    
    }
    
    }