Description

Appends text to the page-output stream. This function writes to the page-output stream regardless of conditions established by the cfsetting tag.

Category

Other functionsSystem functionsData output functions

Function syntax

WriteOutput(string [,encodefor])

History

Introduced in ColdFusion 4.5

Parameters

Parameter

Description

string

A string or a variable that contains one.

encodefor

This parameter's functionality is similar to the 'encodeFor' functions.

The valid values are html, htmlattribute, url, javascript, css, xml, xmlattribute, xpath, ldap, and dn. Based on the respective value, the encoding will be applied on the input string. This parameter is optional.

See also

Usage

Within the cfquery and cfmail tags, this function does not output to the current page; it writes to the current SQL statement or mail text. Do not use WriteOutput within cfquery and cfmail. Although you can call this function anywhere within a page, it is most useful inside a cfscript block.

Examples

<cfscript>
    // encodeFor=url
    writeoutput("encoding for url: ");
    writeoutput("lorem ipsum _*&%^$%&@","url");
</cfscript>

The example above produces the output:

encoding for url: lorem+ipsum+_*%26%25%5E%24%25%26%40

<cfscript>
    // encodeFor=html
    writeoutput("encoding for html: ");
    writeoutput("lorem ipsum _*&%^$%&@","html");
</cfscript>

The example above produces the output:

encoding for html: lorem ipsum _&#x2a;&amp;&#x25;&#x5e;&#x24;&#x25;&amp;&#x40;

<cfscript>
    // encodeFor=css
    writeoutput("encoding for css: ");
    writeoutput("lorem ipsum _*&%^$%&@","css");
</cfscript>

The above example produces the following output:

encoding for css: lorem\20 ipsum\20 \5f \2a \26 \25 \5e \24 \25 \26 \40

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy