Velocity API: View.insertHtml()

Version 2

    Return To Index

    View.insertHtml()

    Overview

    Inserts HTML text and tags from a resource file into a Web screen or all Web screens from the host. The HTML file must be in the resource bundle. The file may contain unformatted text, or text inside standard HTML tags. The text in the file is copied onto the screen in the location specified.

     

    This option is only available for Web hosts.

    Use case

    • Your site was not initially designed to accommodate mobile device screens and requires additional HTML to display properly.
    • You want to insert a warning that prevents users from making a common mistake, but don't want to change your host.

    Format

     

    View.insertHtml (resourceName, tag, position, 
        {'MATCH-URL':urlfrag, 'MATCH-SOURCE':searchText});
    );
    ParameterDescriptionTypeRequiredNotes
    resourceNameThe name of the HTML or HTM file in the resource bundle.TextRequiredDo not specify a path, just the file name. For example:
    'htmlinjection.htm'
    tagSpecifies the name of the tag where the HTML will be inserted.TextRequiredValid values:

     

    "HEAD" - Specifies that the code should be inserted between the <head></head> tags of the page.

     

    "BODY" - Specifies that the code should be inserted between the <body></body> tags of the page.
    positionSpecifies where in the tag that the HTML will be inserted.TextRequiredValid values:

     

    "TOP" - Specifies that the code should be inserted at the top of the specified tag.

     

    "BOTTOM" - Specifies that the code should be inserted at the bottom of specified tag.
    urlfragSpecifies the partial or full URL of the page where you want to insert the HTML. For example:
    'page2.html'
    'company/page2.html'
    StringOptionalPart of the matching parameters object. It must be in the following format, enclosed in braces:
    {'MATCH-URL':'URL'}
    The URL must match at least a portion of the host profile address. If you want the HTML to be added to all pages, do not use the matching parameters object.
    searchTextSpecifies a text string that must match text on the page.StringOptionalPart of the matching parameters object. It must be in the following format, enclosed in braces:
    {'MATCH-SOURCE':'TEXT'}
    The text must be matched exactly, or the HTML is not inserted. It is case-sensitive. If you want the HTML to be added to all pages, do not use the matching parameters object.

     

    Example

    /* Insert specific text from htmlinjection.html within the 
    * BOTTOM of the BODY tag on the page2.html screen.
    */
      
    View.insertHtml('htmlinjection.html', 'BODY', 'BOTTOM', {'MATCH-URL':'page2.html'});