Cập nhật ngày 14/05/2022
<!DOCTYPE html> <html> <head> <title>01.php</title> <style type="text/css"> html, body { width: 100%; height: 96%; margin: 0; } #inp, #out { width: 92%; height: 40%; margin-bottom: 10px; padding: 2%; margin: 2%; } #inp { border-radius: 5px; } #out { border: none; background-color: #ccffcc; } h1 { text-align: center; margin-bottom: 0px; } </style> <script language="javascript"> onload = main; var inp, out; function main() { inp = document.getElementById("inp"); out = document.getElementById("out"); inp.addEventListener("keyup", charsToAsciiCode, false); function charsToAsciiCode() { text = inp.value; out.value = text.split('').map(function(c) { return '&#' + c.charCodeAt(0) + ';'; }).join(''); } charsToAsciiCode(); } </script> </head> <body> <h1>Chuyển đổi văn bản thành HTML ASCII</h1> <textarea id="inp">NguyenTuAnh 2009</textarea> <textarea id="out"></textarea> </body> </html>
Nguồn: NguyenTuAnh 2009