htmlEscape

Prev Next

The $htmlEscape function converts HTML specific control characters so that they are no longer interpreted as HTML code.

For example, a quotation mark (') is converted to &quot; and a lowercase character (<) is converted to &lt.

If such a text is drawn as HTML (e.g. label element, grid cell), then these characters would be output as text instead of being interpreted by the browser as HTML.

Tooltip

Syntax: $htmlEscape(valueToEscape)

Parameter

Description

valueToEscape

The text, which is after HTML control characters such as <,>,", etc.

Returns the passed text with coded HTML specific control characters.

Syntax

$htmlEscape(valueToEscape)

Parameter

Name

Description

valueToEscape

The text that follows HTML control characters e.g. <,>,', etc.

Return value

Returns the passed text with encoded HTML specific control characters.

Example

In a label element (which interprets and renders HTML) a text is to be output, which should not be interpreted as HTML.

The text is 'Please specify<from> and <to>!'.

The representation in a label element interpreted as HTML would now look like this:

'Please specify!'

Because <from> and <to> were interpreted by the browser as HTML markup tags and therefore no longer appear as text.

This can be prevented by the following calculation expression.

$htmlEscape(Please specify <from> and <to>!)

The output on the screen is now as desired:

'Please specify<from> and <to>!'

Because the browser evaluates the following text 'Please &lt;from&gt; and &lt;to&gt; specify!' and therefore finds no HTML markup.