从数据库读的时候在转比 要是有滚动条可能不能显示了吧要不加上style="width:100%;overflow-y:visible;" styleClass="input_off" readonly="true"

解决方案 »

  1.   


    //自定义firefox的innerText
    function isIE()
    { //ie?
        if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1)
            return true;
        else
            return false;
    }if (!isIE())
    { //firefox innerText define
        HTMLElement.prototype.__defineGetter__("innerText",
                function()
                {
                    var anyString = "";
                    var childS = this.childNodes;
                    for (var i = 0; i < childS.length; i++)
                    {
                        if (childS[i].nodeType == 1)
                            anyString += childS[i].tagName == "BR" ? '\n' : childS[i].innerText;
                        else if (childS[i].nodeType == 3)
                            anyString += childS[i].nodeValue;
                    }
                    return anyString;
                }
              );
        HTMLElement.prototype.__defineSetter__("innerText",
                function(sText)
                {
                    this.textContent = sText;
                }
              );
    }
    //html的解码
    WLControl.htmlDecode=function(html)
    {
        var div=document.createElement("div");
        div.innerHTML=html;
        return div.innerText;
    }
    //   \和"的转换,涉及json,按具体情况而定
    text = text.replace(/\\/g, "\\\\\\\\");
    text = text.replace(/\"/g, "\\\\\\\"");
      

  2.   

    如果对安全没威胁可以的,最好<>等也要转建议找个HTML编辑器,如 fckeditor 就挺好用, 处理你的需求没问题。