-
escape html functionJavascript 2020. 8. 6. 17:33
https://coderwall.com/p/ostduq/escape-html-with-javascript
(function(){ "use strict"; function escapeHtml() { return this.replace(/[&<>"'\/]/g, function (s) { var entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; return entityMap[s]; }); } if (typeof(String.prototype.escapeHtml) !== 'function') { String.prototype.escapeHtml = escapeHtml; } })();
굉장하다..
'Javascript' 카테고리의 다른 글
uri decode 방법 (0) 2020.11.23 [Javascript] Event Bubbling / Event Capturing / Event Delegation (0) 2020.02.28 [Javascript] DOMContentLoaded / load 비교 (0) 2020.02.28 Ajax (0) 2020.02.24 [Javascript / Servlet] Ajax POST로 보낸 JSON 데이터 Servlet에서 받아오기 (0) 2020.02.24