<style type="text/css">.stWord { font-family: Times New Roman; font-size : 12pt; } </style> <table align="center" border="0" cellspacing="0" width="400" class="colorborder"> <tr> <td> конвертер code2text <hr> <div> <input id="checkSym1" type="checkbox" checked="checked"/><; <input id="checkSym2" type="checkbox" checked="checked"/>>; <input id="checkSym3" type="checkbox" />"; <input id="checkSym4" type="checkbox"/>&; <input id="checkSym5" type="checkbox"/>~; <input id="checkSym6" type="checkbox" />'; <input id="checkSym7" type="checkbox" />пробел; <input id="checkSym8" type="checkbox" />div; </div> <div>нерабочая: <img onclick="alert('hello');" src="image.jpg" /></div> <div>правильно: <img onclick="alert('hello');" src="image.jpg" /></div> <div>Введите текст HTML</div> <div><textarea class="stWord" cols="60" id="textHTML1" rows="5" width="100"><img onclick="alert('hello');" src="image.jpg" /></textarea></div> <div><input onclick="ConvertHTML();" type="button" value="результат" /></div> <div><textarea class="stWord" cols="60" id="textHTML2" rows="5" width="100"> </textarea></div> </td> </tr> </tbody> </table> <script> function ConvertHTML() { var text1 = document.getElementById('textHTML1').value; var text2 = ''; var tempSym = ''; if (document.getElementById('checkSym8').checked) {text2 = text2 + '<div>';}; for (var i = 0; i < text1.length; i++) { tempSym = text1[i]; if (document.getElementById('checkSym1').checked) if (text1[i] === '<') {tempSym = '<'}; if (document.getElementById('checkSym2').checked) if (text1[i] === '>') {tempSym = '>'}; if (document.getElementById('checkSym3').checked) if (text1[i] === '"') {tempSym = '"'}; if (document.getElementById('checkSym4').checked) if (text1[i] === '&') {tempSym = '&'}; if (document.getElementById('checkSym5').checked) if (text1[i] === '~') {tempSym = '˜'}; if (document.getElementById('checkSym7').checked) if (text1[i] === ' ') {tempSym = ' '}; if (document.getElementById('checkSym8').checked) if (text1[i] === '\n') {tempSym = '</div>' + text1[i] +'<div>'}; if (document.getElementById('checkSym6').checked) if (text1[i] === "'") {tempSym = '''}; text2 = text2 + tempSym; } if (document.getElementById('checkSym8').checked) {text2 = text2 + '</div>';}; document.getElementById('textHTML2').value = text2; } ConvertHTML(); </script>