Return to Snippet

Revision: 22778
at January 22, 2010 03:10 by Nick___


Initial Code
String.prototype.htmlEscape = function() 
  {return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/\>/g,'&gt;')}


// test it out...
alert( '<a href="/?foo=1&bar=2"> blah </a>'.htmlEscape() );

Initial URL

                                

Initial Description

                                

Initial Title
Escape HTML (one-liner)

Initial Tags

                                

Initial Language
JavaScript