2019.1

Table Of Contents
Skin/Formats/CrossReferencePrintFormat("Remote snippets" on page1)).To quickly get the
location of an HTML snippet in the template resources, right-click the snippet in the Resources pane
and select Copy Resource Location.The path to a remote HTML snippet can be copied from the
snippet's properties: right-click the snippet in the Resources pane and select
Properties.selectorString. 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 Skin/Formats/CrossReferencePrintFormat("results" on
page1)).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').children(); results.replaceWith
(snippet);The next script loads a remote snippet (see Skin/Formats/CrossReferencePrintFormat
("Remote snippets" on page1)), looks for an H1 heading and uses that text.var post = loadhtml
('snippets/post.rhtml');var h1 = query('h1', post).text();results.text(h1);Another example is given in
the following how-to: Using a selector to load part of a snippet." on page1)); for JSON, use
loadjson() ("loadjson()" on page802).
Tip
External content is not loaded while editing a script. To test a script that loads external content, you
can do a preflight; see "Doing a Preflight" on page370.
loadtext(location)
Returns the content of a text file. The file extension doesn't have to be .txt. It may also be a
JavaScript file (.js) or a style sheet (.css), for instance.
location
String containing a path that can either be a URL or a path that is relative to the
section/context.
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.js.
Examples
This script loads a JavaScript file (from the Resources pane) directly into a <script> element.
Page 805