How to use the jquery editor plugin tinyMCE

How to use the jquery editor plugin tinyMCE

Modify the simplified file size and download the example: Download the file to your local computer. You can also download the latest jQuery-based code from the official website: https://www.jb51.net/codes/44180.html

1 html

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

2 js reference

First reference tiny_mce.js and jquery-1.4.2.min.js

Calling tinyMCE:

Copy code
The code is as follows:

<script type="text/javascript">
tinyMCE.init({
// General parameter configuration
mode : "textareas",
theme : "advanced",
plugins :"pagebreak,style,layer,table,save",
// Theme parameter configuration
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,
// You can replace your own style here
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>

Parameter details:

mode: textareas or exact
elements: used with exact in mode, its value is the id or name of the textarea to be used in HTML
theme: The style used
Skin: Find the style in the corresponding skin directory
skin_variant: The css file selected in the skin directory, such as: skin_variant: "black" means: skins\o2k7\ui_black.css
plugins: Select and use plugins in the plugins folder
theme_advanced_buttons1: The first row of function buttons is displayed, and so on theme_advanced_buttons2 and so on
3. Add an image to the input box through js and display it. The js code is as follows:
tinyMCE.execCommand('mceInsertContent',false,"<p><img src=\"../images/house.jpg\" alt=\"\" width=\"588\" height=\"419\" /></p>");
Get the content of the input box through js, the code is as follows:
tinyMCE.getInstanceById('txtcontent').getBody().innerHTML

<<:  MyBatis dynamic SQL comprehensive explanation

>>:  CSS to achieve the image hovering mouse folding effect

Recommend

How to count the number of specific characters in a file in Linux

Counting the number of a string in a file is actu...

Experience in solving tomcat memory overflow problem

Some time ago, I submitted a product version to t...

Detailed explanation of the use of umask under Linux

I recently started learning Linux. After reading ...

Use CSS's clip-path property to display irregular graphics

clip-path CSS properties use clipping to create t...

5 cool and practical HTML tags and attributes introduction

In fact, this is also a clickbait title, and it c...

CSS eight eye-catching HOVER effect sample code

1. Send effect HTML <div id="send-btn&quo...

Detailed configuration of mysql8.x docker remote access

Table of contents Environmental conditions Errors...

Solution to the failure of entering the container due to full docker space

Since the problem occurred rather suddenly and th...

How to install Nginx in CentOS

Official documentation: https://nginx.org/en/linu...

Vue-cli creates a project and analyzes the project structure

Table of contents 1. Enter a directory and create...

JS implements simple addition and subtraction of shopping cart effects

This article example shares the specific code of ...

HTML table markup tutorial (16): title horizontal alignment attribute ALIGN

By default, the table title is horizontally cente...

A brief discussion on Linux virtual memory

Table of contents origin Virtual Memory Paging an...