This method escapes all &, <, and > symbols in the string, making it safe to display the string on a web page without fear that it will be treated as HTML.
Code:<html> <head> <title>Strings</title> </head> <body> <script type="text/javascript"> String.prototype.htmlEntities = function () { return this.replace(/&/g,'&').replace(/</g,'<').replace (/>/g,'>'); }; var tmp = '<html><head></head>'; var safe= tmp.htmlEntities(); document.write(safe); </script> <p> This is the other way around, showing html tags' by simply using the "<code></code>" tags. <code><p> some example of common tag's and p tags' is one of them</p></code> </body></html>



Reply With Quote

Bookmarks