duanniesui6391 2013-11-16 08:17
浏览 26

如何显示格式化的html标签

I have a div which is editable, my users adds content into it and sometimes they adds html tags and saves into the database, now when I retrieve the text using php it is showing me the html tags rather then formatting it.

For example:

<div id='content' contentEditable='true'>
   This is a html <a href='www.google.com' >formatted</a><strong>text</strong>
</div>

JavaScript, how I am posting:

var content = encodeURIComponent(document.getElementById('content').innerHTML);
{post content}

PHP, how I am displaying:

echo $_POST['content'];

It is displaying the link with proper default blue colored and underlined but the <strong> and <bold> tags display as it is without the default HTML format.

This is how I am getting :

This is a html formatted<strong>text<strong>

This is how I wanted to display:

This is a html formatted text

  • 写回答

1条回答 默认 最新

  • doushi4795 2013-11-16 08:48
    关注

    Per what I can see your problem is caused by

    encodeURIComponent()
    

    Try to comment it out and see what happens.

    评论

报告相同问题?

悬赏问题

  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件