Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function htmlspecialchars(text) {
  2.     var specialChars = {
  3.         "<": "&lt;",
  4.         ">": "&gt;",
  5.         "'": "&#39;",
  6.         '"': "&quot;",
  7.         "&": "&amp;"
  8.     };
  9.     return text.replace(/[<>'"&]/g, function(s) { return specialChars[s] });
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement