thinkPHP下ueditor的使用方法詳解_php執行個體

來源:互聯網
上載者:User

本文執行個體講述了thinkPHP下ueditor的使用方法。分享給大家供大家參考,具體如下:

1、首先需要下載ueditor,下載地址:http://ueditor.baidu.com/website/download.html

2、下載對應的php版的,下載後重新命名為ueditor,根據需要放到對應的項目目錄中。我放的位置為Public/admin檔案夾下,admin為背景訪問入口檔案目錄。

3、在項目中的使用

首先需要引入核心的js檔案:

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/ueditor.config.js"></script><script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/ueditor.all.js"></script>

然後再檔案中加入<textarea>標籤,注意設定id屬性

複製代碼 代碼如下:
<textarea name="content" id="EditorId"> </textarea>

接著是初始化編輯器,注意配置路徑

<script type="text/javascript" charset="utf-8">window.UEDITOR_HOME_URL = "__PUBLIC__/admin/ueditor/";window.onload=function(){window.UEDITOR_CONFIG.initialFrameHeight=300;//編輯器的高度   window.UEDITOR_CONFIG.initialFrameWidth=800;//編輯器的寬度   var editor = new UE.ui.Editor({imageUrl : '__APP__/Editor/uploadImage',fileUrl : '__APP__/Editor/uploadFile',imagePath : '',filePath : '',imageManagerUrl:'__APP__/Editor/imageManage', //圖片線上管理的處理地址imageManagerPath:'__ROOT__/'});editor.render("EditorId");}</script>

注意:

1、UEDITOR_HOME_URL的路徑配置為ueditor所在的位置。
2、圖片上傳路徑的配置
3、editor.render("textarea的id一致");

至此一個便算基本完成。

但是,在IE9下,編輯器沒有一點效果,這是怎麼回事呢?

在IE9下,需要把

複製代碼 代碼如下:
window.UEDITOR_HOME_URL = "__PUBLIC__/ueditor/";

路徑設定代碼,放在引入js檔案和初始化之間。

希望本文所述對大家基於thinkPHP架構的php程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.