本篇要介紹讓我靠北煩惱兩天的東西,用CKEditor.net版的,如何在前台使用javascript插入數值。

假設您是使用FCKEditor就是不是3.X版以後的話輸入

<script type="text/javascript" language="javascript">
window.FCKeditorAPI.GetInstance('<%=元件名稱.ClientID%>').InsertHtml('要丟入裡面的東西');
</script>

3.X版以後的

<script type="text/javascript" language="javascript">
function InsertPic(vW, vH, vPic) {
var vPicEx = "<img src=\"" + vPic + "\" width=\"" + vW + "\" height=\"" + vH + "\">";
var cKEditorId = '<%=FCKeditor1.ClientID%>';
vPicEx = window.CKEDITOR.instances[cKEditorId].getData() + vPicEx;
window.CKEDITOR.instances[cKEditorId].setData(vPicEx);
}

</script>


上述先用getData()再用setData()是因為只掛setData()他會不鳥已經存在的資料。

附上官網說明

http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setData

arrow
arrow
    文章標籤
    ckeditor
    全站熱搜

    balance 發表在 痞客邦 留言(0) 人氣()