2018.2

Table Of Contents
Tip
External content is not loaded while editing a script. To test a script that loads external content, you
can do a preflight; see "Preflight" on page732.
loadhtml(location)
Loads all HTML 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 page642).
Examples
This script loads a local HTML snippet (from the Resources panel) directly into the matched
elements
results.loadhtml("snippets/snippet.html");
The following script loads a local HTML snippet (Resources panel) into a variable. The
replaceWith() command is used to replace the element(s) matched by the script's selector with
the contents of the snippet.
var mysnippet = loadhtml('snippets/snippet.html');
results.replaceWith(mysnippet);
Same result as the previous script, but a different notation:
results.replaceWith(loadhtml('snippets/snippet.html'));
Page 1149