eWebEditor是個很好用的工具,見面也很好看。是一款很受歡迎的在線編輯器。現在我和大家分享一 下我近期使用eWebEditor遇到的問題及其解決辦法。(這裡先聲明,我使用的是飛魚修改版的eWebEditor )
1.關於eWebEditor不兼容IE8的問題。
在網上查了一下,發現原因是這樣的,因為ie8屏蔽了anonymous方法 所以要改成onclick方法。修改 如下
打開include下面的editor.js文件,有這樣的段代碼:
if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()");
應該修改成:
1if(navigator.appVersion.match(/MSIE (8)\./i)!=null){
2 if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "onclick(event)");
3}else{
4 if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()");
5}
在網上找的某一片文章,它講IE7也認為是屏蔽了anonymous方法,經過個人測試,IE7和IE6一樣,沒 有屏蔽anonymous,故無需對IE7進行判斷,但是這裡有個問題,就是IE8的bate版無法進行判斷,如果高 手請指點一下。
2.使用編輯器提交的內容為空的時候,tomcat服務器會自動關閉的問題。
我的辦法是:
1function getHTML() {
2 var html;
3 if(bEditMode){
4 html = eWebEditor.document.body.innerHTML;
5 }else{
6 html = eWebEditor.document.body.innerText;
7 }
8 var re = new RegExp(sBaseUrl.replace(/\//,"\/"),"gi");
9 html = html.replace(re, "");
10 if ((html.toLowerCase()=="<p> </p>")||(html.toLowerCase()
=="<p></p>")){
11 html = ".";
12 }
13 return html;
14}
但是這並不能找到問題的根源,後來在javaeye的一篇文章裡看到問題的根源。
在upload.jsp裡有這麼一行代碼:
1if(sTemp.equals(""))
2{
3System.exit(0);
4}
應該改為:
if(sTemp.equals(""))
{
sTemp=" "}
3.當eWebEditor不在root的一級目錄的時候,圖片和文件上傳不了的問題。
這需要改兩個地方。以我的某個項目為例:

我的eWebEditor在網站的二級目錄。
a.修改文件的保存路徑:
在upload.jsp裡修改這句話為:
1String sUploadFilePath="jpkc/eWebEditor/UploadFile/";
b.修創建文件夾的路徑:
在eWebEditor.jsp裡修改這句話:
1sStyleNameAdd=config.getServletContext().getRealPath("/")+ "jpkc/eWebEditor/" +
sUploadFilePath +calendar.get(Calendar.YEAR) +
2 "/"+ (calendar.get(Calendar.MONTH)+1) +"/"+ calendar.get(Calendar.DAY_OF_MONTH)
+"/";
到此,eWebEditor又可以上傳文件和圖片了。
雖然eWebEditor外觀很好看,而且還有上傳文件的功能,但是,它有如下缺陷:
1.它是收費的,所以公司做項目一般不用它。
2.它不支持火狐和opera浏覽器。(FCKeditor就很強大啦。)