Replaces special characters in a string with their HTML-escaped equivalents.
HTML-escaped string string. Returns are removed from string. Special characters (for example < " &) are escaped.
Display and formatting functions
HTMLEditFormat(string [, version ])
| Parameter | Description |
|---|---|
| string |
A string or a variable that contains one. |
| version |
HTML version to use.
|
This function increases the length of a string. This can cause unpredictable results when performing certain string functions (Left, Right, and Mid, for example) against the expanded string.
<!--- Shows the use of HTMLCodeFormat and HTMLEditFormat --->
<h3>HTMLEditFormat Example</h3>
<form action = "HTMLeditformat.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 have passed a url address in the FORM, we want to
display the passed address --->
<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 the following address:
http://localhost/cfdocs/index.htm</h4>
<cfelse>
<!--- otherwise use address passed from form --->
<cfset urlAddress = "#FORM.urladdress#">
</cfif>
<!--- now 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>