html()

In a Control Script, the html() function of a section or Master Page can be used to get the initial contents of its <body>, and modify them. This makes it possible, for example, to populate a section or Master Page with elements retrieved from a Content Management system, before Standard Scripts run.

html()

Gets the initial contents of the <body> of a section or Master Page.

html(value)

Replaces the contents of the <body> of a section or Master Page with the supplied value. This function is only available in Control Scripts. See also: section and masterpage.

value

A String that may contain HTML tags.

Examples

The following script uses html() to retrieve the contents of a section and add a paragraph to it.

Copy
var foo = merge.context.sections["Section 1"].html();
foo += "<p>hello world</p>";
merge.context.sections["Section 1"].html( foo );

The following script loads a snippet based on the value of a field, and then replaces the content of a Print section with the snippet using html().

Copy
var mySection = merge.context.sections["Section 1"];
var promoTxt = loadhtml('snippets/promo-' + record.fields['City'] + '.html');
mySection.html(promoTxt);