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() {}

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 htmlbody.

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" />

Fork me on GitHub