1.7

Table Of Contents
The following script loads a snippet into a variable and finds/replaces text in the variable before
inserting the content into the page. The second find command also adds formatting to the
replacing text.
var mysnippet = loadhtml('snippets/snippet.html');
mysnippet.find('@var1@').text('OL Connect 1');
mysnippet.find('@var2@').html('<i>OL Connect 2</i>').css('text-
decoration','underline');
results.replaceWith(mysnippet);
This last script loads a snippet into a variable and retrieves an element from the snippet using
query().
var mysnippet = loadhtml('snippets/text-root-wrapped.html');
var subject = query("#subject", mysnippet).text();
results.append("<p style='font-weight: bold;'>" + subject +
"</p>");
loadhtml(location, selector)
Retrieves specific content from the specified HTML file.
location
String; the location can be absolute or relative to the section/context. Use: snippets/<snippet-
name> to retrieve the contentfrom a HTML file residing in snippets folder of the Resources
panel.
selector
String. The supplied selector should conform to CSS selector syntaxand allows you to
retrieve only the content of matching elements.
Examples
This script loads a specific element from a snippet and uses that to replace the results (the
HTML element or set of HTML elements matched by the selector of the script; see "results" on
page810).
var mysnippet = loadhtml('snippets/snippet-
selectors.html','#item3');
results.replaceWith(mysnippet);
This script loads the children of the selected element.
Page 800