Skip to content

Instantly share code, notes, and snippets.

@lanqy

lanqy/_encodeHTML.js

Created Mar 22, 2013
Embed
What would you like to do?
转换特殊字符
_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
You can’t perform that action at this time.