CKeditor 3.x plugins - Create a custom button that will open a new link
-
01-06-2021 - |
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 )}
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