SinaEditor USES the method in detail

  • 2020-03-30 01:09:44
  • OfStack

1. Download SinaEditor

2.JSP calls the page


<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>

Among them, the SRC = "< % = request. GetContextPath () % > /edit/ edit.htm represents the path of the edit.htm file in the downloaded SinaEditor; The green ID must be the same

3. The downloaded editor contains img. HTM and attach. HTM. The first one is for uploading pictures, the second one is for uploading attachments.

4. The following is an example of uploading pictures in img.htm. Make notes for next time.


function chk_imgpath () {
    if($('radio1').checked==true){
   if($("imgpath").value == "http://" || $("imgpath").value == "") {
    window.close();
    return;
   }
   LoadIMG($("imgpath").value);
    }else{
       if($("file1").value == "") {
       alert(" Please choose to upload the picture file! ");
       return;
       }
       var filepath = j("#file1").val();
       var filetype = filepath.substring(filepath.lastIndexOf('.'));
       var regu = ".gif.jpg.png.jpge.GIF.JPG.PNG";     

    if (regu.indexOf(filetype) == -1) {     
         alert(' Upload only allowed .gif.jpg.png.jpge  Type of file !'); 
         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();
                   $('divProcessing').style.display='';
             },
             error : function(data){
                 alert(' File upload failed ');
             }
           });
    }
  }

5. Background code writing (not described)


Related articles: