Skip to content

Instantly share code, notes, and snippets.

@lanqy
Created March 22, 2013 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanqy/5218238 to your computer and use it in GitHub Desktop.
Save lanqy/5218238 to your computer and use it in GitHub Desktop.
转换特殊字符
_encodeHTML: function(source){ //转换特殊字符
return source.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, "&quot;")
.replace(/\(/g, "&#40;")
.replace(/\)/g, "&#41;")
.replace(/\$/g, "&#36;")
.replace(/'/g, "&#39;");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment