关于转义字符如何显示到页面来,项目急求,谢谢

tingyingg 2015-01-13 03:17:19
我项目用到了UEditor,获取的内容包含了html,也就是保存了格式的,但显示到页面时:

<p><span style="color: rgb(0, 0, 0); font-family: 宋体, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 28px; orphans: auto; text-align: start; text-indent: 31.99919891357422px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: rgb(255, 255, 255);">一名葡萄牙记者希望诺伊尔和梅西评价C罗过去一年的表现</span><span style="color: rgb(0, 0, 0); font-family: 宋体, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 28px; orphans: auto; text-align: start; text-indent: 31.99919891357422px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: rgb(255, 255, 255);">一名葡萄牙记者希望诺伊尔和梅西评价C罗过去一年的表现</span><span style="color: rgb(0, 0, 0); font-family: 宋体, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 28px; orphans: auto; text-align: start; text-indent: 31.99919891357422px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: rgb(255, 255, 255);">一名葡萄牙记者希望诺伊尔和梅西评价C罗过去一年的表现</span><span style="color: rgb(0, 0, 0); font-family: 宋体, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 28px; orphans: auto; text-align: start; text-indent: 31.99919891357422px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: rgb(255, 255, 255);">一名葡萄牙记者希望诺伊尔和梅西评价C罗过去一年的表现</span></p>

所以怎么解决了,谢谢了。
...全文
239 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
未知数 2015-01-13
  • 打赏
  • 举报
回复
把html实体还原为原字符即可(如<替换为<),但有风险,可能被注入代码,要确认输入者可信,或该系统无需考虑安全问题,否则不建议这么做。你也可以尝试用UEditor提供的方法输出,毕竟是该控件录入的
zhangsf1982 2015-01-13
  • 打赏
  • 举报
回复
1. 修改获取代码,不要包含html格式内容 2.显示的时候以html输出,而不是作为文本输出 3.输出前写代码处理清除掉 html的格式内容

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧