cfhtmlbody

Writes the text specified in the text attribute to the 'body' section of a generated HTML page. The cfhtmlbody tag can be useful for embedding JavaScript code, or placing other HTML tags that should go at the bottom of the page just before the closing body tag.

  <cfhtmlbody>

 cfhtmlbody() {}

Attribute Reference

action string
Default: append

possible actions are:
append (default): append text to the HTML body
read: return the text already set to HTML body
reset: reset/remove text already set to HTML body
write: write text to HTML body, overwrite already existing text in HTML head
flush: writes the buffer in the HTML head to the response stream
Values:
  • append
  • read
  • reset
  • write
  • flush

variable string

Name of variable to contain the text for HTML body.

id string

ID of the snippet that is added, used to ensure that the same snippet will not be added more than once.

text string

The text to add to the 'body' area of an HTML page. Alternatively if a closing tag is used then the body between the tags is used.

force boolean

if set to true, it works even within a silent block

Examples
Sample code using the cfhtmlbody tag

Lucee tag wrap

<cfhtmlbody><h1>Hello World</h1></cfhtmlbody>

<cfhtmlbody text='<h1>Hello World</h1>' />'>

cfhtmlbody( text='<h1>Hello World</h1>');

Overwriting, reading, flushing

<cfhtmlbody action="write"><h1>Overwrite Body Buffer</h1></cfhtmlbody>
<cfhtmlbody action="read" variable="body"></cfhtmlbody>
<cfoutput><b>#body#</b></cfoutput>
<cfhtmlbody action="reset" />
<cfhtmlbody><h1>New Body</h1></cfhtmlbody>
<cfhtmlbody action="flush" />

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub