Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

apostrophe issue in javascript

var entityMap = {
    "&": "&",
    "<": "&lt;",
    ">": "&gt;",
    '"': '&quot;',
    "'": '&#39;',
    "/": '&#x2F;'
};

function escapeHtml(string) {
    return String(string).replace(/[&<>"'/]/g, function (s) {
        return entityMap[s];
    });
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #apostrophe #issue #javascript
ADD COMMENT
Topic
Name
8+5 =