{"id":827,"date":"2007-06-15T14:08:14","date_gmt":"2007-06-15T08:38:14","guid":{"rendered":"http:\/\/www.chiragmehta.info\/chirag\/2007\/06\/15\/javascript-htmlencodehtmldecode\/"},"modified":"2007-06-15T14:08:14","modified_gmt":"2007-06-15T08:38:14","slug":"javascript-htmlencodehtmldecode","status":"publish","type":"post","link":"https:\/\/www.chiragmehta.info\/chirag\/2007\/06\/15\/javascript-htmlencodehtmldecode\/","title":{"rendered":"Javascript HtmlEncode\/HtmlDecode"},"content":{"rendered":"<p>Ack:- <a href = \"http:\/\/lunarmedia.com\/blogs\/lunarmedia_blog\/archive\/2006\/10\/23\/120405.aspx\">Lunar Media<\/a><\/p>\n<p>Have you ever needed to HtmlEncode a querystring using JavaScript? Yes you may say, and several people will claim that you should UrlEncode it using escape(str); For some unknown reason I tried doing exactly that and UrlDecode the variable in csharp with no luck. Instead I found a solution in the Prototype library, appropriately they call it escapeHTML:<\/p>\n<p>function escapeHTML (str)<br \/>\n{<br \/>\n   var div = document.createElement(&#8216;div&#8217;);<br \/>\n   var text = document.createTextNode(str);<br \/>\n   div.appendChild(text);<br \/>\n   return div.innerHTML;<br \/>\n};<\/p>\n<p>Wonderful simple and effective trick using the browsers own automatic Html converter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ack:- Lunar Media Have you ever needed to HtmlEncode a querystring using JavaScript? Yes you may say, and several people will claim that you should UrlEncode it using escape(str); For some unknown reason I tried doing exactly that and UrlDecode the variable in csharp with no luck. Instead I found a solution in the Prototype [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[27],"class_list":["post-827","post","type-post","status-publish","format-standard","hentry","tag-javascript","post-preview"],"_links":{"self":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/comments?post=827"}],"version-history":[{"count":0,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/posts\/827\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/media?parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/categories?post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chiragmehta.info\/chirag\/wp-json\/wp\/v2\/tags?post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}