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

MySQL implements an example method of logging in without a password

Specific method: Step 1: Stop the mysql service /...

About installing python3.8 image in docker

Docker Hub official website 1. Search for Python ...

Example usage of JavaScript tamper-proof object

Table of contents javascript tamper-proof object ...

JavaScript modularity explained

Table of contents Preface: 1. Concept 2. The bene...

Analysis of the principle of Rabbitmq heartbea heartbeat detection mechanism

Preface When using RabbitMQ, if there is no traff...

Summary of seven sorting algorithms implemented in JavaScript (recommended!)

Table of contents Preface Bubble Sort Basic Algor...

Use of Linux relative and absolute paths

01. Overview Absolute paths and relative paths ar...

JavaScript Reflection Learning Tips

Table of contents 1. Introduction 2. Interface 3....

JS version of the picture magnifying glass effect

This article shares the specific code of JS to ac...

Docker deploys nginx and mounts folders and file operations

During this period of time, I was studying docker...

How to use and limit props in react

The props of the component (props is an object) F...

How to use lodop print control in Vue to achieve browser compatible printing

Preface This control will have a watermark at the...

VMWare15 installs Mac OS system (graphic tutorial)

Installation Environment WIN10 VMware Workstation...