110,473
社区成员
发帖
与我相关
我的任务
分享
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;
}
function HTMLDecode(text)
{
var temp = document.createElement("div");
temp.innerHTML = text;
var output = temp.innerText || temp.textContent;
temp = null;
return output;
}
存数据库后,存进去后再取字符串,asp.net中可以通过HtmlDecode解码显示,编码、解码方式:
string strHtmlEncode = Server.HtmlEncode(strHtml);
string strHtmlDecode = Server.HtmlDecode(strHtmlEncode);