나는 JavaScript와 jsp의 콤보를 가지고 있는데, 그것은 몇 가지 텍스트를 추가하고 그것을 벗어나고있다. 나 또한 그것이 제출 된 후 텍스트를 편집 할 수 있도록 일부 javascrpt있다. 그러나 html은 편집 버튼을 클릭 할 때 렌더링됩니다.javascript를 사용하여 "innerHtml"속성에서 html을 이스케이프 처리하려면 어떻게해야합니까?
function editCommentToggle(id)
{
theRow = document.getElementById("id"+id);
//user = theRow.cells[0].innerHTML;
//date = theRow.cells[1].innerHTML;
--> com = theRow.cells[2].innerHTML;
idx = 2;
maxlength = 250;
// Comment field
cell = theRow.cells[idx];
while(cell.childNodes.length > 0) cell.removeChild(cell.childNodes[0]);
element = document.createElement("textarea");
element.id="comments-"+id;
element.rows="3";
element.value = com;
element.style.width = "400px";
element.maxLength = "250";
element.onfocus = element.onkeydown = element.onkeyup = function(){return characterCounterEdit(undefined, maxlength, this);};
cell.appendChild(element);
"theRow.cells [2] .innerHTML;"은 그 셀에서 텍스트 나 HTML을 잡아 내고 있지만, '개행'이라고 말하면 <br>
.....을 표시합니다. 어떻게이 구조를 이스케이프 처리 된 html로 유지해야합니까 ??
고맙습니다 (IE 또는 innerText와)
친구 야 ... 시도해 보겠습니다. –
근무했습니다. –