これは、ckeditor を起動するために用意したテキストエリアです。
<textarea name="Message" id="RFMessage lol" rows="4" class="ckeditor" onkeydown="if(this.value.length>=1024)this.value=this.value.substring(0,1023);">
</textarea>
私がこのhtmlを持っているよりも:
<textarea id="message" class="message hide" >WORLDWIDE,Any</textarea>
私がする必要があるのは、JS を .message div で動作させて ",Any" を取り除き、"WORLDWIDE" のみのクリーンな値を #RFMessage div に入れることです。
ckeditor 内でカスタム JS を実行する方法がわからないので、ここから定義済みの API を使用しています: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html
InsertHTML を使用して値を取得し、挿入します。
これは私のJS全体です:
<script>
$(".message").each(function() {
$(this).html($(this).html().replace(/,Any/g,""));
$(this).html($(this).html().replace(/Any,/g,""));
});
</script>
<script>
CKEDITOR.on( 'instanceReady', function( ev ) {
var oEditor = CKEDITOR.instances.RFMessage;
var value = document.getElementById('message').value;
oEditor.insertHtml(value);
});
</script>
もちろん、CKEditor にはこのすべてをロードする必要があります。
Chrome と Firefox ではすべて正常に動作しますが、IE8 では動作しません
API を使用するこの CKEditor サンプルに従ってスクリプトを作成しました: http://nightly.ckeditor.com/7493/_samples/api.html
これがIE8で機能しない原因は何ですか? また、フォーラムで IE8 関連のバグを調べてみましたが、見つかりませんでした。たぶん、スクリプトに何かが欠けているだけですか?
ありがとう