2009-08-03 71 views
0

我在Firefox中遇到了fckeditor問題。當用戶轉到頁面時,html(編碼)存儲在隱藏的輸入元素中。我調用預定義的fckeditor javascript事件來使用來自隱藏的ContentBody元素的HTML填充我的編輯器。Firefox中隱藏的輸入元素

 function FCKeditor_OnComplete(editorInstance) 
     { 
      editorInstance.InsertHtml(""); 
      var sample = document.getElementById("ContentBody").value; 
      editorInstance.InsertHtml(sample); 
     } 

這會在IE中自動填充所需文本的編輯器,但在Firefox中不會。螢火蟲給我的錯誤:

A爲空[該誤差打破]變種 FCKW3CRange =函數(A){this._Docume ... eateFromRange(this._Document,這一點);}}; \ r \ n

使用Firebug我可以確定事件方法FCKeditor_OnComplete()只是在使用Firefox時未被觸發。但是,在IE中。有關如何使這兩種瀏覽器都能正常工作的想法?

爲ContentBody的HTML是: <input type="hidden" name="ContentBody" id="ContentBody" value="<%=Model.Article%>" />

+0

請編寫HTML代碼 「ContentBody」 – 2009-08-03 21:09:03

+0

請參見上面。感謝您的幫助! – splatto 2009-08-03 21:21:15

回答

0

我來解決這個上個月在一個新的項目時。首先,我的HTML編碼字符串保存在一個隱藏的輸入元素:

<input type="hidden" name="ContentBody" id="ContentBody" value="<%=Model.Body%>" /> 

此功能的情況下被調用時,在完成加載FCKeditor的實例。

function FCKeditor_OnComplete(editorInstance) 
{ 
    var oEditor = FCKeditorAPI.GetInstance(editorInstance.Name); 
    var content = parent.document.getElementById("ContentBody").value; 
    var EditedContent = content.replace(/\u201C/g, '"'); 
    oEditor.InsertHtml(EditedContent); 
    content = null; 
} 

看來火狐需要的JavaScript調用parent.document.getElementById()

0

你確定你的標籤有屬性ID = 「ContentBody」?可以使用屬性name =「ContentBody」,IE將(在技術上不正確)將其解釋爲getElementById的ID屬性。只有你正確使用了id,Firefox纔會找到它。

0

如果你打破了錯誤並走上堆棧,爲什麼A沒有設置?或者,打破

document.getElementById("ContentBody").value

,並走在堆棧,尋找一個更具體的原因。

1

這很有趣。我從來沒有使用FCKeditorOnComplete(我不得不刪除下劃線來使WMD快樂),但它看起來像一個很好的鉤子。您是否嘗試在下面的FCKEditor函數中設置一個斷點?你使用Firefox到達那裏嗎?也許這是事做在您FCKeditorOnComplete物理位於...

function WaitForActive(editorInstance, newStatus) 
267...{ 
268 if (newStatus == FCK_STATUS_ACTIVE) 
269 ...{ 
270  if (FCKBrowserInfo.IsGecko) 
271   FCKTools.RunFunction(window.onresize) ; 
272 
273  _AttachFormSubmitToAPI() ; 
274 
275  FCK.SetStatus(FCK_STATUS_COMPLETE) ; 
276 
277  // Call the special "FCKeditor_OnComplete" function that should be present in 
278  // the HTML page where the editor is located. 
279  if (typeof(window.parent.FCKeditor_OnComplete) == 'function') 
280   window.parent.FCKeditor_OnComplete(FCK) ; 
281 } 
282}