从数据库取出的用富文本编辑器编辑过的图文消息,直接显示在网页上怎么原样输出呢?

骑着蜗牛@you 2016-10-26 01:28:30
数据能从数据库拿出来,像标题之类的字段动能显示,唯独富文本编辑过的内容显示不出来;请大神们帮忙解决!!!!

<script type="text/javascript">

$(document).ready(function(){
$.ajax({
type:'post',
url:'getNewsByNewId.html',
dataType:'json',
success:function(data){

alert(data);
//alert($('#newsTitle').val(data.theme););
//alert(data.theme);
alert(data.content);
//alert(data.author);
$('#newsTitle').val(data.theme);
$('#newsAuthor').val(data.author);
$('#checker').val(data.checker);

$('#editor').val(data.content);
//UE.getEditor('editor').setContent(data.content);
}
});
});
</script>
上面是我从后台拿数据的代码;

<body>

<form action="newsAdd.html" id="editor_id" name="newsadd" method="post">
<div id="login">
<a class="login_txt_bt" ><h1>新闻消息录入</h1></a>
</div>
<br/>
<div>
新闻标题:    <input type="text" id=newsTitle name="newsTitle" style="width:220px;height:15px;" tabindex="1"></input>
</div>
<br/>
<div>
新闻作者:    <input type="text" id=newsAuthor name="newsAuthor" style="width:150px;height:15px;" tabindex="2"></input>
</div>
<br/>
<div>
审核人为:    <input type="text" id=checker name="checker" style="width:150px;height:15px;" tabindex="2"></input>
</div>
<br/>
<div>
新闻栏目:    <select id="section" name="section" style="width:105px;height:20px;"tabindex="3"></select>
</div>
<br/>
<div>
<script id="editor" name="content" type="text/plain" style="width:1000px;height:200px;"></script>
</div>
<div>
<button onclick="getAllHtml()">获得整个html的内容</button>
<button onclick="getContent()">获得内容</button>
<button onclick="setContent()">写入内容</button>

</div>
<br/>
<input type="submit" id="button" name="button" value="提交" tabindex="6" />
</form>
<script type="text/javascript">

//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');

function getAllHtml() {
alert(UE.getEditor('editor').getAllHtml())
}
function getContent() {
var arr = [];
arr.push("使用editor.getContent()方法可以获得编辑器的内容");
arr.push("内容为:");
arr.push(UE.getEditor('editor').getContent());
alert(arr.join("\n"));
}
</script>
</body>
这是加载编辑器的代码
...全文
4841 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
我也想弄明白
  • 打赏
  • 举报
回复
问个问题,用富文本编辑过的数据,存到数据库中,取出来的时候还是编辑时候的样子吗?比如:格式和换行,颜色之类的和存之前在富文本编辑器中编辑的一样吗
骑着蜗牛@you 2017-07-31
  • 打赏
  • 举报
回复
引用 3 楼 qq_36116927 的回复:
我也遇到同样的问题,最后你是怎么解决的呢
放弃了,你弄出来了吗
qq_36116927 2017-04-16
  • 打赏
  • 举报
回复
我也遇到同样的问题,最后你是怎么解决的呢
slwsss 2016-10-26
  • 打赏
  • 举报
回复
调试下 估计js错了
骑着蜗牛@you 2016-10-26
  • 打赏
  • 举报
回复
有没有大神帮忙看下子啊

87,907

社区成员

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

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