首页 > 代码库 > js转码和解码兼容低版本火狐

js转码和解码兼容低版本火狐

    function HTMLEncode(html) {
                var temp = document.createElement("div");
                (temp.innerText != null) ? (temp.innerText = html) : (temp.textContent = html);
                var output = temp.innerHTML;
                temp = null;
                return output;
            }
            function HTMLDecode(text) {
                var temp = document.createElement("div");
                temp.innerHTML = text;
                var output = temp.innerText || temp.textContent;
                temp = null;
                return output;
            }

js转码和解码兼容低版本火狐