HTML Online Editor does not need to know how to use Dreamweaver. Word will use this editor with Word. It is very practical in the Web program that requires text editing in the article system or news system.
But how to embed the HTML editor into the web page and how to get the data inside? Intersection
First of all, we assume that we have to call the HTML online editor in a separate page. The file name is GLEDIT.HTM uploading the front desk page of the picture: http://www.jfinfo.com/roDmin/img_upload.asp.
HTML Online Editor has two basic call methods
1. Use object call (http://www.jfinfo.com/rodmin/editor.asp):
1. How to embed the html editor in the web page: We need to embed the location of the HTML code: <object ID = DOC_HTML DATA = "GLEDIT.HTM" WIDTH = 530 Height = 320 Type = Text/X-Scriptlet XT> </object>
Among them, the data after the Object label is obtained by the Data is the way we want to call the online editor page. The ID is that we call the Object to get the ID, and this ID must be used when the data is obtained in the editor. Width and Height are high and width of the editor.
2. How to get the data in the HTML editor: All the contents that need to be submitted are placed in a form, and editors that are also used by Object are also placed in this form. At the same time Textarea name = "Content" style = "Display: None"> </TextArea> or <input type = "hidden" name = "content">) The data of the HTML online editor temporarily saved the HTML online editor when submitting, because ASP or JSP, you cannot directly obtain the content of Object in the form, so we must use the hidden text area to obtain data. We copy the content in Object into the hidden text area while submitting the form. The detailed code is as follows:
<script language = "javascript">
Function Checkform ()
{{
document.form1.content.Value = document.form1.doc_html.value;
}
</script>
<FORM METHOD = "Post" action = "add_news_save.asp" onsubmit = "Checkform ()" name = "form1">
<object ID = doc_html name = doc_html style = "left: 0px; TOP: 0px" data = "gibeit.htm" width = 530 height = 320 type = text/X-Scriptlet XT> </Object>
<input type = "hidden" name = "content">
</form>
In this way, in the background processing page, we can directly obtain the data of the HTML online editor by taking data from the hidden area.
3. How to add upload this machine picture to the HTML online editor in the text editor: First of all, we pop up a window uploading the picture when clicking the button that is inserted into the picture. On the server, we need to record the path of the picture, and then add the HTML label to the display picture through the value of the HTML online editor. Detailed instructions and code are as follows:
In the editor, we add the event on the button on the picture onCLICK = "Window.open ('IMG_UPLOAD.ASP', 'IMG_UPLOAD', 'WIDTH = 481 Height = 190')"> "Img_upload.asp 'we will be in' img_upload.asp ' The submitted picture Upload to the server to formulate a directory and record the picture path
<script language = javascript>
var src = '<%= "upload/" & newame%>';
opener.Form1. DOC_HTML.VALUE = "<IMG Border = 0 SRC =" SRC ">" ";
window.close ();
</script>
In this way, simply insert the uploaded picture into the editor.
4. How to call the HTML online editor when editing modify the article to modify the data: When we add the data to the database when we add the data to the database Let's modify the data. First of all, we add a hidden area in the form to place the contents of the database, such as <textarea style = "display: none" name = "content" rows = "20" color = "70"> <%= rs ("content" )%> </Textarea>, pay attention to us with hidden Textarea without the hidden input, because the data may contain a car Enter, so if we use <input Type = "Hidden" name = Content Value = " <%= (RS ("Content")%> "> It is likely to appear html errors due to <%= (" content ")%> in the change (value = the data later connected must be guaranteed to be in one line, otherwise there will be an error. ). Then use Object to call the HTML online editor by Object. The method and code are the same as above. Now what we have to do is actually the reverse process when submitting. Here we add <body only = "document.form1. DOC_HTML.VALUE = DOCUMENT.FORM1.VALUE">, so that when the page is loaded, the content of the database can be placed in HTML The editor is edited in the online editor. The submission process is the same as the above, so I won't go into details here.
Second, use iframe call (http://qxd.5599.net/by/source/article/manage/gledit.htm)
1. How to embed in the web page: We need to embed the location to add the following html code: <iframe src = "gibeit.htm" id = 'content_html' style = "left: 0px; put: 0px; z; z; z -Index: 0 "> </iframe> Among them," src = "The data connected later is the way we want to call the online editor page. ID is that we call iframe to ID, width and height are the height and width of the editor. Essence
2. How to get the data in the html editor: The same content that needs to be submitted is placed in a form. At the same time, we can set up a hidden text area > </textarea> or <input type = "hidden" name = "content">) to temporarily save the data of the HTML online editor when submitting, we use the hidden text area to obtain data. We copy the content in Object into the hidden text area while submitting the form. The detailed code is as follows: