2017-07-31 9 views
0

ローカルhtmlページをckeditorにロードする方法はありますか?ckeditor内にhtmlページをロード

<div class="text-area"> 
    <textarea cols="120" rows="10" id="editor" name="text"></textarea> 
</div> 

これはスクリプトです:

@section Scripts { 
<script type="text/javascript"> 

    CKEDITOR.replace('editor', { 
     fullPage: true, 
     allowedContent: true  

    }); 

    CKEDITOR.instances['editor'].setData('test.html'); 

</script> 
} 
+0

あなたは親切に、私に知らせてもらえ、してください? – iXCray

+0

はい、それはうまくいったが、いくつかの理由でエディタを変更した。とにかく助けてくれてありがとう。 –

答えて

1

あなたはなめらかで、このページをロードするだけにして、あなたが得たデータとCKEditorバージョンを入力する必要があります。エディタ内のデータが適切に変更されたことの確認を得ただろうまで.setData()は非同期関数であることを

は、そう、右後の任意のデータ変更をしません。

Javascriptを:

var xhr = new XMLHttpRequest(); 
xhr.open('GET', 'test.html', true); 

xhr.onload = function() { 
    if (this.status == 200) { 
    CKEDITOR.instances['editor'].setData(this.response); 
    } else { 
    // process error status here 
    } 
}; 

xhr.onerror = function() { 
    // process error status here 
}; 

xhr.send(); 

Javascriptを+ jQueryの

$.get('test.html') 
    .done(response=>{CKEDITOR.instances['editor'].setData(response);}) 
    .fail(/** process error here **/); 

Javascriptを+すべてのブラウザはこの1つをサポートしているわけではありません

をフェッチします。

ポリフィルはここにある:https://github.com/github/fetch

サポート表はこちらです:ソリューション提供がうまく働いていた場合https://caniuse.com/#search=fetch

fetch('test.html') 
    .then(response=>{CKEDITOR.instances['editor'].setData(response.text);}) 
    .catch(/** process error here **/); 
関連する問題