开发者

retrieve the text from HTMLbox

Does anyone know how to retrieve the text from HTMLbox rich t开发者_如何学JAVAext editior?


Htmlbox is just an plugin that extends upon the html element textarea .You can treat it like normal textarea html element. For eg..

$(function()
{
 $('#textboxid').htmlbox({
        toolbars:[
             [
            "separator","bold","italic","underline","strike","sup","sub",
            "separator","removeformat"
            ],
            ["separator","fontsize","fontfamily","fontcolor","highlight"]
        ],
        skin:"blue"
        });
alert($('#textboxid').val());
}


To use HtmlBox's built-in functions, do this: Assign the return of htmlbox() to a variable and then call HtmlBox's methods using that variable (e.g. hb_full.get_html(); or any other method). See code example below.

<script type="text/javascript">
    var hb_full;
$(document).ready(function(){
        hb_full = $("#htmlbox_full").css("height", "300").css("width", "100%").htmlbox({
            toolbars: [
                [
                    // Cut, Copy, Paste
                    "separator", "cut", "copy", "paste",
                    // Undo, Redo
                    "separator", "undo", "redo",
                    // Bold, Italic, Underline, Strikethrough, Sup, Sub
                    "separator", "bold", "italic", "underline", "strike", "sup", "sub",
                    // Left, Right, Center, Justify
                    "separator", "justify", "left", "center", "right",
                    // Ordered List, Unordered List, Indent, Outdent
                    "separator", "ol", "ul", "indent", "outdent",
                    // Hyperlink, Remove Hyperlink, Image
                    "separator", "link", "unlink", "image"
                ],
                [
                    // Show code
                    "separator", "code",
                            // Formats, Font size, Font family, Font color, Font, Background
                    "separator", "formats", "fontsize", "fontfamily",
                    "separator", "fontcolor", "highlight",
                ],
                [
                    //Strip tags
                    "separator", "removeformat", "striptags", "hr", "paragraph",
                    // Styles, Source code syntax buttons
                    "separator", "quote", "styles", "syntax"
                ]
            ],
            about: true, // "false" to hide About button
            idir: "./img/HtmlBoxImg/",
            icons: "default", //all options: "default", "silk"
            skin: "blue"      //all options: "silver", "blue", "green", "red"
        });
    });

    function getHtmlFromEditor()
    {
        var HtmlFromEditor = hb_full.get_html();
        alert(HtmlFromEditor);
    }
    </script>

    <textarea id="htmlbox_full"></textarea>
<button onclick="getHtmlFromEditor();">Display HTML</button>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜