Tuesday, August 16, 2016




Sometimes when we try to display some HTML code in our websites or blogs, we face major difficulties. This is because the websites and blogs are created with HTML (Hyper Text Markup Language), and when we try to display HTML codes in these documents, the codes that are meant to be displayed, also gets executed by the web browsers. As a result, we only get to see results instead of those codes. We can bypass this problem by escaping the special HTML characters. I have made the following JavaScript tool to escape the HTML characters. Hope you'll find it useful:

HTML Special Character Escape Tool


Input code:






Escaped code:



Here is the source code. You can paste it anywhere inside your body tag:

<div style="margin:auto; display:inline-block;">
   <h3>HTML Special Character Escape Tool</h3>
   <h4>Input code:</h4>
    <textarea style="width:100%; height:90px; resize:none;" id="infld"></textarea><br /><br />
    <button style="float:right; background-color:#015264; color: white; text-align:center; border:none; padding:5px;" type="submit" onclick="escapeHtml()">Submit</button><br /><br />
    <h4>Escaped code:</h4>
    <textarea style="width:100%; height:90px; resize:none;" id="outfld"></textarea><br /><br />
    </div>
    <script>
    function escapeHtml() {
        var text = document.getElementById('infld').value;
  var change = {
    '&': '&amp;',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    "'": '&#039;'
  };

  document.getElementById('outfld').value = text.replace(/[&<>"']/g, function(c) { return change[c]; });
}
    </script>


You can use the HTML Special Character UnEscape Tool here.



Related Posts:

  • If your motherboard circuits got burned then there is no way you can fix it. But if a virus deletes your BIOS then your motherboard will stop working. There will be no POST operation. You'll get no display on your monit…
  • Sometimes we need to unpublish blogger (blogspot) post without deletion. Because every post we write requires some effort. We don't know when we will need it again. So here is how to do it:- 1. Login to Blog…
  • You can split large files with Winrar. Here is how - - Right click the file you want to split. Click "Add to archive". - Select your desired file size from the combo box under the "Split to volumes size" section. …
  • First step of building a PC is collecting the required parts. Here is what you need to assemble a desktop computer:- 1. Case - A case is needed to set all the devices of the computer in it. 2. Power Supply Un…
  • Many people do not have high memory RAM in their computers. As a result their PC runs slow. This problem can be solved by using the pendrive as RAM. To do this you need minimum 2GB of pendrive. For Windows XP: - Connect…

0 comments:

Post a Comment