html 反转义
2015-12-24 14:01
274 查看
html 转义前的代码如下
转义后的代码如下
<responseData class="java.lang.String"><?xml version="1.0" encoding="UTF-8"?>
<Responses><Response><ServerIP>10.2.5.154</ServerIP><total>0</total><time>6</time><result/><tokens>hotel an der h ?žš rn é—‡??ˆ é–°?Ž‘ ?Ž‘?°μ</tokens><landmark/></Response></Responses></responseData>
转义js函数如下:
function HTMLDecode(text)
{
var temp = document.createElement("div");
temp.innerHTML = text;
var output = temp.innerText || temp.textContent;
temp = null;
console.log(output)
}
调用方式:
console.log(HTMLDecode('需要反转义的html代码'))
转义后的代码如下
<responseData class="java.lang.String"><?xml version="1.0" encoding="UTF-8"?>
<Responses><Response><ServerIP>10.2.5.154</ServerIP><total>0</total><time>6</time><result/><tokens>hotel an der h ?žš rn é—‡??ˆ é–°?Ž‘ ?Ž‘?°μ</tokens><landmark/></Response></Responses></responseData>
转义js函数如下:
function HTMLDecode(text)
{
var temp = document.createElement("div");
temp.innerHTML = text;
var output = temp.innerText || temp.textContent;
temp = null;
console.log(output)
}
调用方式:
console.log(HTMLDecode('需要反转义的html代码'))
相关文章推荐
- Beego 字符串转HTML问题
- HTML 5 video 视频标签全属性详解
- 常用HTML字符实体
- html初识1
- HTML本地测试成功后上传博客注意事项
- <学习笔记> html事件(源w3school)
- html canvas[autodyne] image clipping
- html中超链接颜色改变,实际项目可能用到
- 浏览器编辑HTML
- HTML中标签的属性ID与Name的区别!
- html的相关基础元素(二)
- html的相关基础元素(一)
- 实现侧边栏工具(1)使用背景图片方式
- html标签总结
- HTML--表格与表单(练习做注册页面)
- HTML——表单与锚点
- HTML 一分钟编写网页播放器
- 初学HTML 需要注意什么
- HTML--网页练习--(360导航首页的一部分)
- smarty截取字符串与过滤HTML标签