In this article you will know how to create a simple text editor on the page.
To start, create a new HTML file and include the required source files in it.
If you use dhtmlxEditor standalone you need to include 2 files:
<!DOCTYPE html>
<html>
<head>
<title>Quick start with dhtmlxEditor</title>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlxeditor.css"> <script src="codebase/dhtmlxeditor.js"></script></head>
<body>
<script> //your code here
</script>
</body>
</html>
If you use dhtmlxEditor as a part of "dhtmlxSuite" package you need to include 2 files:
<link rel="STYLESHEET" type="text/css" href="../codebase/dhtmlx.css">
<script src="../codebase/dhtmlx.js" type="text/javascript"></script>
To include JS/CSS files of "dhtmlxSuite" package from CDN, you should set direct links to dhtmlx.js and dhtmlx.css files:
<link rel="stylesheet" href="http://cdn.dhtmlx.com/edge/dhtmlx.css"
type="text/css">
<script src="http://cdn.dhtmlx.com/edge/dhtmlx.js"
type="text/javascript"></script>
By setting links in this way you will get the latest version of dhtmlxSuite. To get some particular version, just specify the number of the required version in the link, like this:
<link rel="stylesheet" href="http://cdn.dhtmlx.com/5.0/dhtmlx.css"
type="text/css">
<script src="http://cdn.dhtmlx.com/5.0/dhtmlx.js"
type="text/javascript"></script>
Create a HTML container on the page (where later you will put in an editor):
<!DOCTYPE html>
<html>
<head>
<title>Quick start with dhtmlxEditor</title>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlxeditor.css">
<script src="codebase/dhtmlxeditor.js"></script>
</head>
<body>
<div id="editorObj" style="width:100%; height:300px; border:#909090 1px solid;"></div> <script> //your code here
</script>
</body>
</html>
Create a new dhtmlXEditor's object in the HTML container:
<!DOCTYPE html>
<html>
<head>
<title>Quick start with dhtmlxEditor</title>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlxeditor.css">
<script src="codebase/dhtmlxeditor.js"></script>
</head>
<body>
<div id="editorObj" style="width:100%; height:300px; border:#909090 1px solid;"></div>
<script> var myEditor = new dhtmlXEditor("editorObj");
</script>
</body>
</html>
You can also initialize dhtmlxEditor using the object notation.
Call the setContent method to set the initial text in the editor.
Note, you can use any HTML while setting the text.
var myEditor = new dhtmlXEditor("editorObj");
myEditor.setContent("Please, type your comments here");
Back to top