0

Firefoxのfckeditorで問題が発生しています。ユーザーがページに移動すると、html(エンコードされた)は非表示の入力要素に保存されます。事前定義されたfckeditorjavascriptイベントを呼び出して、非表示のContentBody要素からのhtmlをエディターに入力します。

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

これにより、IEではエディタに目的のテキストが自動的に入力されますが、Firefoxでは入力されません。Firebugは私にエラーを与えます:

Aはnullです[このエラーを中断します]varFCKW3CRange = function(A){this._Docume ... eateFromRange(this._Document、this);}}; \ r \ n

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

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

4

4 に答える 4

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}
于 2009-08-05T19:37:30.420 に答える
0

エラーを壊してスタックを上っていくと、なぜAが設定されないのですか?または、中断します

document.getElementById("ContentBody").value

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

于 2009-08-03T23:38:13.413 に答える
0

タグの属性がid="ContentBody"でよろ​​しいですか?属性name="ContentBody"を使用することは可能であり、IEはそれをgetElementByIdのID属性として(技術的に誤って)解釈します。Firefoxは、idを正しく使用した場合にのみそれを検出します。

于 2009-08-03T21:10:50.840 に答える
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;
}

Firefoxでは、parent.document.getElementById()を呼び出すためにJavaScriptが必要なようです。

于 2010-03-26T13:51:56.487 に答える