almost 3 years ago
escape.html
請輸入測試字串,例如:<  >
<input type="text" id="text" />
<button id="btn">轉換</button>
<br>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
    $('#btn').on('click', function(){
        $('#text').val(escapeHtml($('#text').val()));
    });

    function escapeHtml(unsafe) {
        return unsafe
             .replace(/&/g, "&amp;")
             .replace(/</g, "&lt;")
             .replace(/>/g, "&gt;")
             .replace(/"/g, "&quot;")
             .replace(/'/g, "&#039;");
     }
</script>
← 關於httponly mysql prepared statements →