Home php教程 php手册 jquery编辑器插件tinyMCE介绍

jquery编辑器插件tinyMCE介绍

Jun 01, 2016 am 09:46 AM
tinymce

修改简化文件大小后的案例下载:下载文件到本地 也可以到官方网站下载最新的基于jquery的.

1 html

<code class="language-html"><textarea id="txtcontent" runat="server" name="elm1″ rows=" cols="80″ style=" width:80></textarea></code>
Copy after login

2 js引用

首先引用tiny_mce.js和jquery-1.4.2.min.js

tinyMCE的调用:

<code class="language-html"><script type="text/javascript">
tinyMCE.init({
// 通用参数配置
mode : "textareas",
theme : "advanced",
plugins :"pagebreak,style,layer,table,save",
// 主题参数配置
theme_advanced_buttons1 :",bold,italic,underline,strikethrough",
theme_advanced_buttons2 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// 在此处可以更换您自己的样式
content_css : "css/word.css",
external_link_list_url : "lists/link_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234″
}
});
</script></code>
Copy after login

参数详解:

mode:textareas或者exact
elements:配合mode中exact使用,它的值为html中要使用的textaear的id或name名称
theme:所使用的样式
skin:找到相应的skin目录下样式
skin_variant:skin目录下的文件css选择,如:skin_variant : "black"表示:skins\o2k7\ui_black.css
plugins:plugins文件夹下插件的选择使用
theme_advanced_buttons1:第一行的功能按钮显示,一下以此类推theme_advanced_buttons2等等
3 扩展
向输入框中通过js追加一个图片并显示,js代码如下:

<code class="language-javascript">tinyMCE.execCommand(‘mceInsertContent’,false,"<p><img src="%5C%22../images/house.jpg%5C%22" alt='\"\"'    style="max-width:90%"588\"' height='\"419\"'></p>");</code>
Copy after login

通过js获取输入框内容,代码如下:

<code class="language-javascript">tinyMCE.getInstanceById(‘txtcontent’).getBody().innerHTML</code>
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)