Detailed usage of SinaEditor

Source: Internet
Author: User

1. Download SinaEditor

2. JSP call page
Copy codeThe Code is as follows:
<Textarea name = "problemBody" id = "content" style = "display: none;" textarea>
<Iframe src = "<% = request. getContextPath () %>/edit/editor.htm? Id = content & ReadCookie = 0 "frameBorder =" 0 "marginHeight =" 0 "marginWidth =" 0 "scrolling =" No "width =" 621 "height =" 457 "> </iframe>

The path of the editor.htm file in sinaeditordownloaded by src = "<% = request. getContextPath () %>/edit/editor.htm.pdf; the two IDs with green must be consistent

3.The downloaded editorpackage contains img.htmand attach.htm. The first one is for uploading images, and the second is for uploading attachments. Of course, the two are the same method of use and can be viewed as uploading files.

4.The following is an example of uploading images in img.htm. Make records to facilitate next use.
Copy codeThe Code is as follows:
Function chk_imgpath (){
If ($ ('radio1'). checked = true ){
If ($ ("imgpath"). value = "http: //" | $ ("imgpath"). value = ""){
Window. close ();
Return;
}
LoadIMG ($ ("imgpath"). value );
} Else {
If ($ ("file1"). value = ""){
Alert ("select to upload an image file! ");
Return;
}
Var filepath = j ("# file1"). val ();
Var filetype = filepath. substring (filepath. lastIndexOf ('.'));
Var regu = ".gif.jpg.png.jpg e. GIF. JPG. PNG ";

If (regu. indexOf (filetype) =-1 ){
Alert('only upload .gif.jpg.png.jpg e files allowed! ');
Return;
}
Var f = j ('# form1 ');
J. ajaxFileUpload ({
Type: 'post ',
Secureuri: false,
FileElementId: 'file1 ',
Url: '/ask/fileUpload? Type = img ',
DataType: 'string ',
Success: function (data ){
J ("# imgpath"). attr ("value", data );
J ("# radio1"). attr ("checked", "true ");
Chk_imgpath ();
$ ('Didprocessing'). style. display = '';
},
Error: function (data ){
Alert ('file upload failed ');
}
});
}
}

5. Write background Code (not described)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.