Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not JavaScript which "unescapes" the characters, but the HTML parser which decodes the entities. It's expected behaviour.</p> <p>If it does not sound logical to you, tell me how you would put a double and a single quote in an attribute.</p> <pre><code>&lt;div tltip=""'"&gt; does not work. &lt;div tltip="&amp;quot;'"&gt; does work. &lt;div tltip='"&amp;#39;'&gt; does work. &lt;div tltip="&amp;quot;&amp;#39;"&gt; does work. </code></pre> <p><em>Regarding the edited question</em><br> You don't have to read the original source code. For instance:</p> <pre><code>&lt;div tltip="&amp;lt;b&amp;gt;test&amp;lt;/b&amp;gt;" id="test"&gt;&lt;/div&gt; var output1 = document.getElementById('html'); var output2 = document.getElementById('plain'); var attrValue = document.getElementById('test').getAttribute('tltip'); output1.innerHTML = attrValue; output2.textContent = attrValue; </code></pre> <p>Will render as:</p> <p>Output 1: <b>test</b><br> Output 2: &lt;b&gt;test&lt;/b&gt;</p> <p><code>textContent</code> is not supported in old IE versions. A cross-browser compatible way is:</p> <pre><code>output2[document.textContent === null ? 'textContent' : 'innerText'] = attrValue; // OR output2.innerHTML = ''; // Empty contents output2.appendChild(document.createTextNode(attrValue)); </code></pre> <hr> <p>If you still want to decode the entities, then the following will work:</p> <pre><code>// &lt;b&gt; -&gt; &amp;lt;b&amp;gt; function decode(strHTML) { var tmp = document.createElement('div'); tmp.appendChild(document.createTextNode(strHTML)); return tmp.innerHTML; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload