Friday Quick Tip: HTMLEditFormat for JavaScript
Posted By : todd sharp Posted At : July 24, 2009 10:43 PM Posted In: jQuery, JavaScript
4
I just came across a handy little function that emulates ColdFusion's HTMLEditFormat() function. It's quite simple really, but it worked perfectly since I wanted to display some HTML as text (instead of rendering it). Here it is should you ever finding yourself with a need to do the same:
return h.split("&").join("& amp;").split( "<").join("& lt;").split(">").join("& gt;");
}
Note: to use the function remove the space after each & - I had to put that in to prevent my blog from rendering them.
I should point also point out that Chris Jordan has a complete package of JavaScript functions that emulate ColdFusion built in functions on RIAForge called CFJS. The package is built to work with jQuery (FTW). I haven't tried it out yet, but from what I hear it comes in handy.



