2018.1

Table Of Contents
loadhtml(location, selector)
Retrieves specific content from the specified HTML file.
location
String containing a path that can be absolute or relative to the section/context.
Use snippets/<snippet-name> to retrieve the content from an HTML file residing in the
Snippets folder on the Resources panel.
In order to retrieve files from outside the template, the file protocol is supported as well as
the http/https protocols.
The complete syntax of a fully qualified URL with the "file" protocol is: file://<host>/<path>. If
the host is "localhost", it can be omitted, resulting in file:///<path>, for example:
file:///c:/somefolder/somecontent.html.
When using the http/https protocol, remember that only absolute paths are supported inside
remote snippets (see "Remote snippets" on page612).
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
page1026).
var mysnippet = loadhtml('snippets/snippet-
selectors.html','#item3');
results.replaceWith(mysnippet);
This script loads the children of the selected element.
var snippet = loadhtml
('file:///C:/Users/PParker/Documents/Example.html','foobar').childr
en();
results.replaceWith(snippet);
The next script loads a remote snippet (see "Remote snippets" on page612), looks for an H1
heading and uses that text.
Page 1069