Forms such as:
Copy Code code as follows:
Varoeditor=fckeditorapi.getinstance (' content ');
Varcontent=oeditor.getxhtml (TRUE);
*************************************************
Using JavaScript to fetch and set FCKeditor values is also very easy, as follows:
Copy Code code as follows:
Get HTML content in editor
function Geteditorhtmlcontents (editorname) {
var oeditor = fckeditorapi.getinstance (editorname);
Return (Oeditor.getxhtml (true));
}
Get text in Editor
function Geteditortextcontents (editorname) {
var oeditor = fckeditorapi.getinstance (editorname);
return (OEditor.EditorDocument.body.innerText);
}
Setting the contents of the editor
function seteditorcontents (editorname, contentstr) {
var oeditor = fckeditorapi.getinstance (editorname);
Oeditor.sethtml (CONTENTSTR);
}
Fckeditorapi is a global object that is registered after FCKeditor is loaded, and we can use it to complete various operations on the editor.
Get FCK Editor Instance on current page:
var Editor = fckeditorapi.getinstance (' instancename ');
Get the FCK editor instance from the pop-up window of the FCK editor:
var Editor = window.parent.InnerDialogLoaded (). FCK;
To obtain a FCK editor instance of another child frame from a child frame of a frames page:
var Editor = window. FrameName.FCKeditorAPI.GetInstance (' instancename ');
To get the FCK editor instance of the parent window from the page pop-up window:
var Editor = opener. Fckeditorapi.getinstance (' instancename ');
Get the contents of the FCK Editor:
oeditor.getxhtml (formatted); Formatted as: True|false, indicating whether to remove in HTML format
Also available:
Oeditor.getxhtml ();
To set the contents of the FCK Editor:
oeditor.sethtml ("content", false); The second parameter is: True|false, whether the contents are set in WYSIWYG mode. This method is often used for "set initial value" or "form Reset" Oh.
To insert content into the FCK editor:
oeditor.inserthtml ("HTML"); "HTML" as HTML text
Check if the contents of the FCK editor have changed:
Oeditor.isdirty ();
To invoke the FCK Editor toolbar command outside the FCK editor:
The list of commands is as follows:
Docprops, Templates, Link, Unlink, Anchor, BulletedList, Numberedlist, about, find, Replace, Image, Flash, Specialchar, Sm Iley, Table, Tableprop, Tablecellprop, Universalkey, Style, FontName, FontSize, Fontformat, Source, Preview, Save, newpage , PageBreak, TextColor, bgcolor, Pastetext, Pasteword, Tableinsertrow, Tabledeleterows, Tableinsertcolumn, Tabledeletecolumns, Tableinsertcell, Tabledeletecells, Tablemergecells, Tablesplitcell, TableDelete, Form, Checkbox, Radio, TextField, Textarea, HiddenField, Button, Select, ImageButton, spellcheck, Fitwindow, Undo, Redo
Use the following methods:
OEditor.Commands.GetCommand (' Fitwindow '). Execute ();
= Fckconfig.basepath + ' plugins/'
FCKCONFIG.PLUGINS.ADD (' placeholder ', ' en,it ');
Remove//, it is equivalent to placeholder this plug-in functionality, FCKeditor plug-in files are categorized under the/editor/plugins/folder by folder, For fckeditor2.0, there are two folders, that is, there are two official plug-ins, placeholder This folder is what we have just added, mainly for Multi-parameter or single parameter custom label matching, this is very useful in the production of editing templates, to see specific examples, You can go to download ACMs This system to view learning, another folder Tablecommands is the editor of the table editor used. Of course, if you want to make your own other uses of Plug-ins, then just follow the Fckeidtor plug-in production rules to be placed under/editor/plugins/, and then add FCKConfig.Plugins.Add in Fckeidtor.js (' Plugin Name ', ', Lang,lang '); it's OK.
The second part, how to let the editor open, the editing toolbar does not appear, and so on "expand the toolbar" to appear? Easy,fckeditor itself provides this functionality, open fckconfig.js, and find
Fckconfig.toolbarstartexpanded = true;
Change into
fckconfig.toolbarstartexpanded = false;
You can do it!
The third part, using your own expression icon, also open fckcofnig.js to the bottom of the section
Copy Code code as follows:
Fckconfig.smileypath = Fckconfig.basepath + ' images/smiley/msn/';
Fckconfig.smileyimages = [' regular_smile.gif ', ' sad_smile.gif ', ' wink_smile.gif '];
Fckconfig.smileycolumns = 8;
Fckconfig.smileywindowwidth = 320;
Fckconfig.smileywindowheight = 240;
The above paragraph has been modified by me, in order for me to publish the text of the page will not be too open, I have to fckconfig.smileyimages that line to change only three emoticons.
The first line, of course, is the setting of the expression icon path, the second line is related to the expression icon file name of a list, the third line refers to the expression of the pop-up to add the number of expressions in the window, the following two parameters are pop-up modal window width and height.
Part IV, File Upload Management Section
This section may be the most concerned, the previous article simply talked about how to modify to upload files and use fckeidtor2.0 to provide the fast upload function. And then we continue to explain the upload function
Fckconfig.linkbrowser = true;
Fckconfig.imagebrowser = true;
Fckconfig.flashbrowser = true; Find these three sentences in Fckconfig.js, these three are not connected oh, just I brought them here, set to true means to allow the use of FCKeditor to browse Server-side file images and flash and so on, this feature is when you insert the Picture pop-up window on the "Browse Server" button can be reflected, if your editor is only used for their own use or only in the background management, this feature is very useful, because he lets you very intuitive to the server file upload operation. But if your system to face the foreground user or a system such as blog to use, this security risk can be big oh. So we set it to false;
Fckconfig.linkbrowser = false;
Fckconfig.imagebrowser = false;
Fckconfig.flashbrowser = false;
As a result, we have only a quick upload available ah, good! Next to modify, the same as an example of ASP, into the/editor/filemanager/upload/asp/open config.asp, modify
Configuserfilespath = "/userfiles/" This setting is the total list of uploaded files, I will not move here, you want to change their own
OK, then open the upload.asp file in this directory and find the following section
Copy Code code as follows:
Dim ResourceType
If (Request.QueryString ("Type") <> "") Then
ResourceType = Request.QueryString ("Type")
Else
ResourceType = "File"
End If
And then add it later
Configuserfilespath = Configuserfilespath & ResourceType & "/" & Year (Date ()) & "/" & Month (Date ()) & "/"
In this case, the uploaded file goes into the "/userfiles/file type (such as image or file or Flash)/year/month/" Such a folder, this setting for single user to use is enough, if you want to use for multi-user system, so to change
Configuserfilespath = Configuserfilespath & Session ("username") & resourcetype & "/" & Year (Date ()) & "/" & Month (Date ()) & "/"
This uploads the file into the "/userfiles/User directory/File type/year/month/" Down, of course, if you do not want to this arrangement can also be modified to other, such as the user directory further layer, and so on, here session ("username") please according to their own needs to modify or replace.
Upload the directory set up, but upload the program will not create these folders themselves, if it does not exist, upload will not be successful, then we have to according to the upload path above the request for the return of the directory generated.
Find this section
Copy Code code as follows:
Dim Sserverdir
Sserverdir = Server.MapPath (Configuserfilespath)
If (Right (Sserverdir, 1) <> "\") Then
Sserverdir = sserverdir & "\"
End If
Put the two lines underneath it
Dim oFSO
Set oFSO = Server.CreateObject ("Scripting.FileSystemObject")
Replace it with the following piece of code
Copy Code code as follows:
Dim Arrpath,strtmppath,introw
strTmpPath = ""
Arrpath = Split (Sserverdir, "\")
Dim oFSO
Set oFSO = Server.CreateObject ("Scripting.FileSystemObject")
For introw = 0 to Ubound (arrpath)
strTmpPath = strTmpPath & Arrpath (introw) & "\"
If Ofso.folderexists (strTmpPath) =false Then
Ofso.createfolder (strTmpPath)
End If
Next
Use this code to generate the folder you want, automatically generated when uploading.
Well, upload file changes can now be temporarily closed, but, for Chinese users still have such a problem, is FCKeditor file upload default is not renamed, and also does not support the Chinese file name, so that the uploaded file will become ". jpg" Such an unreadable file, Then there will be duplicate files, of course, the same name is nothing, because FCKeditor will automatically renamed, will be added (1) In this way to identify. However, our usual habit is to have the program automatically generate a duplicate filename
Just below that piece of code, followed by
' Get the uploaded file name.
sFileName = Ouploader.file ("NewFile"). Name
See clearly, this is the filename, we have to change it, of course, there must be a function to generate file name, change to the following
Copy Code code as follows:
'//Get a repeat number
Public Function Getnewid ()
Dim rannum
Dim Dtnow
Randomize
Dtnow=now ()
Rannum=int (90000*RND) +10000
Getnewid=year (Dtnow) & Right ("0" & Month (Dtnow), 2) & Right ("0" & Day (Dtnow), 2) & Right ("0" & Hour ( Dtnow), 2 & Right ("0" & Minute (Dtnow), 2) & Right ("0" & Second (Dtnow), 2) & Rannum
End Function
' Get the uploaded file name.
sFileName = Getnewid () & "." & Split (Ouploader.file ("NewFile"). Name, ".") (1)
In this way, the uploaded file will be automatically renamed to generate a filename such as 20050802122536365.jpg, is the date and time of the year and the three-bit random number of the file name