HTMLEditFormat

Description

Returns HTML escaped string. Carriage returns are removed from string, and special characters (> < " &) are escaped.

Category

Display and formatting functions

Syntax


HTMLEditFormat(string [, version ]) 

See also

HTMLCodeFormat

Parameters

Parameter
Description
string
String to be HTML escaped
version
The HTML version to use. Valid entries are:
  • -1    The latest implementation of HTML
  • 2.0    HTML 2.0 (Default)
  • 3.2    HTML 3.2

Usage

By escaping special characters, 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.

Example

<!--- This example shows the use of HTMLCodeFormat

and HTMLEditFormat --->

<html>

<head>

<title>

HTMLEditFormat Example

</title>

</head>



<body bgcolor = silver>

<H3>HTMLEditFormat Example</H3>



<form action = "HTMLeditformat.cfm" method = "POST">

Try entering a URL for the tag to return in HTMLCodeFormat

and HTMLEditFormat:

<input type = "Text" size = 25 name = "urladdress" 

 value = "http://www.allaire.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>



</body>

</html> 



Banner.Novgorod.Ru