w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Display html code in html page

Use entities, like

var encodeHtmlEntity = function(str) {
  var buf = [];
  for (var i=str.length-1;i>=0;i--) {
    buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
  }
  return buf.join('');
};
bootbox.alert('<pre><code data-language="html">'+
encodeHtmlEntity(document.getElementById('editor').innerHTML)) +
'</code></pre>');




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.