0

当单击位于编辑器旁边的按钮时,如何在新模式窗口中以 html 格式查看 ckeditor 内容。下面是html

 <img  src="Image/icons/preview.png" alt="Preview" id="img1" class="preview"  />

                <textarea rows="30" cols="22" id="txtHtmlHead" class="editor"></textarea>

上面的 textarea 表现为 ckeditor 。

请帮我..

4

1 回答 1

0

你可以用window.open()一个棘手url的方法来做到这一点(小提琴):

CKEDITOR.replace( 'editor', {
    plugins: 'sourcearea,wysiwygarea,toolbar,basicstyles',
    height: 100
} );

// Executen on button click.
function show() {
    var url = 'javascript:void( function(){' +
        'document.open();' +    
        // Note that you may need to escape HTML entities here:
        'document.write( "' + CKEDITOR.instances.editor.getData() + '" );' +
        'document.close();' +
    '})()';    

    window.open( url );
}

官方预览插件也提供了此类功能,因此您可能会觉得它很有趣。

于 2013-09-20T08:41:18.083 回答