jquery编辑器插件tinyMCE的使用方法

网站建设 2023-01-28 20:48www.1681989.com免费网站

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

1 html

<textarea id="txtcontent" runat="server" name="elm1″ rows="15″ cols="80″ style="width:80%"></textarea>

2 js引用

引用ty_mce.js和jquery-1.4.2.m.js

tyMCE的调用

复制代码
代码如下:

<script type="text/javascript">
tyMCE.it({
// 通用参数配置
mode : "textareas",
theme : "advanced",
plugs :"pagebreak,style,layer,table,save",
// 主题参数配置
theme_advanced_buttons1 :",bold,italic,underle,strikethrough",
theme_advanced_buttons2 : "",
theme_advanced_toolbar_location : "",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizg : true,
// 在此处可以更换您自己的样式
content_css : "css/word.css",
external_lk_list_url : "lists/lk_list.js",
// Replace values for the template plug
template_replace_values : {
username : "Some User",
staffid : "991234″
}
});
</script>

参数详解

modetextareas或者exact
elements配合mode中exact使用,它的值为html中要使用的textaear的id或name名称
theme所使用的样式
sk找到相应的sk目录下样式
sk_variantsk目录下的文件css选择,如sk_variant : "black"表示sks\o2k7\ui_black.css
plugsplugs文件夹下插件的选择使用
theme_advanced_buttons1:第一行的功能按钮显示,一下以此类推theme_advanced_buttons2等等
3 扩展
向输入框中通过js追加一个图片并显示,js代码如下
tyMCE.execCommand(‘mceInsertContent’,false,"<p><img src=\"../images/house.jpg\" alt=\"\" width=\"588\" height=\"419\" /></p>");
通过js获取输入框内容,代码如下
tyMCE.getInstanceById(‘txtcontent’).getBody().nerHTML

Copyright © 2016-2025 www.1681989.com 推火网 版权所有 Power by