[转]OBOUT ASP.NET HTML Editor - Insert HTML

本文转自:http://www.obout.com/editor_new/sample_InsertHTML.aspx

Example demonstrates how to access HTML Editor's content at current selection/caret position from "outside" component.

Example code

<script type="text/JavaScript">
function Insert()
{
 oboutGetEditor('editor').InsertHTML("<a href='mailto://support@obout.com'>Obout support</a>");
}
</script> 

<input type="button" onclick="Insert();" value="Insert Obout support link"/> 
 <ed:Editor id="editor" runat="server" /> 

 

具体实例效果见 http://www.obout.com/editor_new/sample_InsertHTML.aspx

 

 

 

另有:http://www.obout.com/Obout.Ajax.UI/HTMLEditor/examples/CSAPI_insertHTML.aspx

Obout.Ajax.UI Controls - HTML Editor - Insert HTML code in the current cursor position

<%@ Register Assembly="Obout.Ajax.UI" Namespace="Obout.Ajax.UI.HTMLEditor" TagPrefix="obout" %>
<input type="button" οnclick="InsertLink();" value="Insert Obout support link"/> 
<br /><br />
<obout:Editor runat="server" Id="editor" Width="100%" >
   <TopToolbar PreservePlace="true" />
   <EditPanel Height="400px" />
</obout:Editor>
...
<script type="text/javascript">
function InsertLink() {
    // get the EditPanel
    var editPanel = $find("<%= editor.ClientID %>").get_editPanel();
    // can be inserted in 'Design' mode only
    if (editPanel.get_activeMode() == Obout.Ajax.UI.HTMLEditor.ActiveModeType.Design) {
       // save content for 'Undo' operation
       editPanel.get_activePanel().SaveContent();
       // insert HTML into current caret position
       editPanel.get_activePanel().insertHTML("<a href='mailto://support@obout.com'>Obout support</a>");
    }
} 
</script>

具体实例效果见http://www.obout.com/Obout.Ajax.UI/HTMLEditor/examples/CSAPI_insertHTML.aspx

 

 

                var editPanel = Obout.Ajax.UI.HTMLEditor.LastFocusedEditPanel;
                // if the current mode is 'Design'
                if (editPanel != null && editPanel.get_activeMode() == Obout.Ajax.UI.HTMLEditor.ActiveModeType.Design) {

                    alert(varHtmlContent);

                    // get the DesignPanel's object

                    var designPanel = editPanel.get_activePanel();

                    // For 'Undo'

                    designPanel._saveContent();

                    // What to do - insert some text at current selection

                    //---------------------------------------------------

                    designPanel.insertHTML("" + "$$" + varHtmlContent + "$$" + "");

                    //---------------------------------------------------

                    // Notify Editor about content changed and update toolbars linked to the edit panel

                    // setTimeout(function () { designPanel.onContentChanged(); editPanel.updateToolbar(); }, 0);

                    // Ensure focus in design panel

                    designPanel.focusEditor();

                }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值