Thinkphp 文本编辑器

文本编辑器:可以从网上下载---ueditor文件夹里面包含php和utf8-php两个文件夹

平时使用时主要用到获取内容写入内容两个按钮

获取内容:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.config.js"></script>
  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.all.min.js"> </script>
    <!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
   <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/lang/zh-cn/zh-cn.js"></script>

</head>

<body>
<div>
<!--文本编辑器显示区域-->
    <script id="editor" type="text/plain" style="width:800px;height:300px;"></script>
</div>
<div>
 <button οnclick="getContent()">获得内容</button>
 <button οnclick="setContent()">写入内容</button>
 </div>
<div id="xianshi"></div>
</body>

<script type="text/javascript">
//实例化文本编辑器,这句话必须有
var ue = UE.getEditor('editor');
function getContent() {
    //主要作用语句    
    //在文本编辑器中写入内容,点击获得内容按钮后,在xianshi<div>里显示内容
document.getElementById("xianshi").innerHTML = UE.getEditor('editor').getContent();
}
       
</script>
</html>
View Code

文本编辑器中写入的内容:

 

xianshi<div>中现实的内容:

 

写入内容:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.config.js"></script>
  <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/ueditor.all.min.js"> </script>
    <!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
   <script type="text/javascript" charset="utf-8" src="ueditor/utf8-php/lang/zh-cn/zh-cn.js"></script>

</head>

<body>
<div>
<!--文本编辑器显示区域-->
    <script id="editor" type="text/plain" style="width:800px;height:300px;"></script>
</div>
<div>
 <button οnclick="getContent()">获得内容</button>
 <button οnclick="setContent()">写入内容</button>
 </div>
<div id="xianshi"></div>
</body>

<script type="text/javascript">
//实例化文本编辑器,这句话必须有
var ue = UE.getEditor('editor');
       
function setContent(isAppendTo) {  
var str = "<p style='white-space: normal;'><span style='background-color: rgb(84, 141, 212);'>斯柯达晶高科的复活节</span><img src='http://localhost:8080/ueditor/php/upload/image/20160704/1467600934975616.png' title='1467600934975616.png' alt='6.png'></p><p style='white-space: normal;'><span style='text-decoration: underline; color: rgb(0, 176, 80);'><em>看电视剧赶快回家回家的撒</em></span></p><p><br></p>";
 //主要作用语句
UE.getEditor('editor').setContent(str, isAppendTo);
}
</script>
</html>
View Code

写入内容前现实的内容:

获取内容代码加到对应的方法中,然后写入内容,显示一样的内容:

转载于:https://www.cnblogs.com/ds-3579/p/5639849.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值