Flamingo.Utils.encodeHTML()

The encodeHTML() method converts specified HTML code into encoded string according to the following table:

Symbol Output Entity
& &
< &#60;
> &#62;
&#34;
&#39;
/ &#47;

Syntax

Flamingo.Utils.encodeHTML(htmlString)

Parameters

Parameter Type Description
htmlString String HTML code for transformation.

Return Value

Type Description
String Encoded string.

Example: Transform HTML into string

The example below demonstrates how to convert HTML code into string.

Source HTML code available on original desktop site page:

<html>
 <body>
   <div id="test"><strong>Test Element</strong></div>
 </body>
</html>

You need to add the following code to your template to convert HTML code defined by test id into string:

<!--{= Flamingo.Utils.encodeHTML(Flamingo.getDocument().getElementById('test').innerHTML) }-->

The result displayed on the mobile website will look like:

&#60;strong&#62;Test Element&#60;&#47;strong&#62;

See also