经典JS的HTML转义与反转义字符
//HTML转义 function HTMLEncode(html) { var temp = document.createElement ("div"); (temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html); var output = temp.innerHTML; temp = null; return output; } //HTML反转义 function HTMLDecode(text) { var temp = document.createElement("div"); temp.innerHTML = text; var output = temp.innerText || temp.textContent; temp = null; return output; }
转载自:http://www.stepday.com/topic/?566
原创作者:http://www.cnblogs.com/huangsheng/