2009-08-03 30 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はVAR FCKW3CRange =関数(A)ヌル[このエラーのブレーク]である{this._Docume ... eateFromRange(this._Document、この);}}; \ R \ n

Firebugを使用すると、Firefoxの使用時にイベントメソッドFCKeditor_OnComplete()が起動しないことがわかります。しかし、それはIEである。両方のブラウザでこれを動作させる方法に関するアイデアはありますか?

ContentBodyためのHTMLは次のとおりです。 <input type="hidden" name="ContentBody" id="ContentBody" value="<%=Model.Article%>" />

+0

は、 "ContentBody" のHTMLコードを記述してください –

+0

上記を参照してくださいparent.document.getElementByIdを呼び出すためにJavaScriptを必要と思われます。助けてくれてありがとう! – splatto

+1

どのようにエディタをインスタンス化しますか?つまり、「新しいFCKeditor」は、ドキュメント全体がロードされた後にのみ実行されますか? –

答えて

0

...あなたのFCKeditorOnCompleteが物理的に配置されている場所とは何かです。まず、私は非表示の入力要素でエンコードされた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; 
} 

それはFirefoxが()

0

あなたのタグが属性ID = "ContentBody" を持っていますか?属性name = "ContentBody"を使用することは可能で、IEはgetElementByIdのID属性としてそれを(技術的に間違って)解釈します。 Firefoxは、idを正しく使用する場合にのみそれを見つけます。

0

エラーでブレークし、スタックを歩くなら、なぜ設定されていないのですか?または、

document.getElementById("ContentBody").value

に分割し、より具体的な原因を探して、スタックを歩きます。

+1

質問では、Firebugが私に与えるエラーを提供しました。 "Firebugが私にエラーを与える...." – splatto

+0

"FireFOXは私にエラーを与える"と誤解しています。 – Josh

+0

私の改訂版の回答をご覧ください。 – Josh

1

これは興味深いことです。私はFCKeditorOnCompleteを使用したことがありませんでした(私はWMDを幸せにするためにアンダースコアを削除しなければなりませんでした)が、それは良いフックのように見えます。このFCKEditor関数のブレークポイントを下に置こうとしましたか?あなたはFirefoxでそこに着きますか?多分新しいプロジェクトに取り組んでいる間、私はこの最後の月にソリューションに来た

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}