CKEditor: set default target to _blank

I recently had a client ask me to set the default target for hyperlinks to "_blank" in CKEditor. Did a little research on it and found many places like this where the good people at CKEditor hint at how one can do it, if only you know your javascript well enough to understand their hint.
Here's exactly how we solved the problem - no hinting or beating around the bush.
Edit your ckeditor/plugins/link/dialogs/link.js file and add the following code to the bottom:
/* Here we are latching on an event ... in this case, the dialog open event */
CKEDITOR.on('dialogDefinition', function(ev) {
try {
/* this just gets the name of the dialog */
var dialogName = ev.data.name;
/* this just gets the contents of the opened dialog */
var dialogDefinition = ev.data.definition;
/* Make sure that the dialog opened is the link plugin ... otherwise do nothing */
if(dialogName == 'link') {
/* Getting the contents of the Target tab */
var informationTab = dialogDefinition.getContents('target');
/* Getting the contents of the dropdown field "Target" so we can set it */
var targetField = informationTab.get('linkTargetType');
/* Now that we have the field, we just set the default to _blank
A good modification would be to check the value of the URL field
and if the field does not start with "mailto:" or a relative path,
then set the value to "_blank" */
targetField['default'] = '_blank';
}
} catch(exception) {
alert('Error ' + ev.message);
}
});
I have included plenty of comments to describe what this function is doing.
Enjoy!
Comments
...aaaand where is this link.js to be found?