Question

I am trying to create a custom button (plugin) on the the CKEditor toolbar that once clicked will open a pre-set URL in a new window - can anyone provide some assistance this is what I've got so far within my plugin.js file.

I basically just want to say once this button is clicked go to a URL in a new window. Any ideas?

CKEDITOR.plugins.add('inserthtml',   {    
requires: ['dialog'],
lang : ['en'], 
init:function(a) { 
var b="inserthtml";
var c=a.addCommand(b,new CKEDITOR.dialogCommand(b));
    c.modes={wysiwyg:1,source:0};
    c.canUndo=false;
a.ui.addButton("inserthtml",{
                label:a.lang.inserthtml.title,
                command:b,
                icon:this.path+"inserthtml.gif"
});
CKEDITOR.dialog.addIframe(b, b, 'http://pixlr.com/express', 800, 640 )} 
});

The error I get in Firebug

CKEDITOR.dialog.addIframe is not a function 
CKEDITOR.dialog.addIframe(b, b, 'http://pixlr.com/express', 800, 640 )}
Was it helpful?

Solution

Instead of using a compressed file with meaningless variable names, follow this tutorial: http://docs.cksource.com/CKEditor_3.x/Tutorials/Timestamp_Plugin and replace the line

editor.insertHtml( 'The current date and time is: <em>' + timestamp.toString() + '</em>' );

with your call to open a window:

window.open('http://pixlr.com/express');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top