Replaces special characters in a string with their HTML-escaped equivalents and inserts <pre> and </pre> tags at the beginning and end of the string.
HTML-escaped string string, enclosed in <pre> and </pre> tags. Returns are removed from string. Special characters (> < " &) are escaped.
Display and formatting functions
HTMLCodeFormat(string [, version ])
| Parameter | Description |
|---|---|
| string |
A string or a variable that contains one. |
| version |
HTML version to use:
|
<!--- Shows the use of HTMLCodeFormat and HTMLEditFormat --->
<h3>HTMLCodeFormat Example</h3>
<form action = "HTMLcodeformat.cfm">
Try entering a URL for the tag to return in HTMLCodeFormat and HTMLEditFormat:
<input type = "Text" size = 25 name = "urladdress"
value = "http://www.macromedia.com">
<input type = "Submit" name = "" value = "get page">
</form>
<!--- sets a default value for a url to retrieve --->
<cfparam name = "urladdress" default = "http://localhost/cfdocs/index.htm">
<!--- if we passed a url address in FORM, we display it --->
<cfif IsDefined("FORM.urladdress") is True>
<!--- do simple error check to avoid crashing the tag --->
<cfif Trim(Form.urladdress) is "" or Trim(Form.urladdress) is "http://">
<!--- if error condition tripped, set alternative --->
<cfset urlAddress = "http://localhost/cfdocs/index.htm">
<h4>because you entered no url or an empty string, the tag will
return this address: http://localhost/cfdocs/index.htm</h4>
<cfelse>
<!--- otherwise use address passed from form --->
<cfset urlAddress = FORM.urladdress>
</cfif>
<!--- use the CFHTTP tag to get the file content represented by urladdress --->
<CFHTTP URL = "#urladdress#"
method = "GET"
RESOLVEURL = YES>
</CFHTTP>
<cfelse>
<!--- the first time through, retrieve a URL that we know exists --->
<CFHTTP URL = "http://localhost/cfdocs/index.htm"
method = "GET"
RESOLVEURL = YES>
</CFHTTP>
</cfif>
<!--- Now, output the file, including the mimetype and content --->
<h3>Show the file</h3>
<cfoutput>
<p>Here is an example of 255 characters from your file output in HTMLCodeFormat:
<p>#HTMLCodeFormat(Mid(CFHTTP.FileContent,1,255))#
<p>Here is an example of 255 characters from your file output in HTMLEditFormat:
<p>#HTMLEditFormat(Mid(CFHTTP.FileContent,1,255))#
</cfoutput>
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6
Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt1115.htm
Comments
chris.caron@telelogi said on Feb 24, 2003 at 5:28 AM : rrcecil said on Aug 28, 2003 at 12:47 PM :