How to change default Target in the TinyMCE 'Insert/Edit Link' dialog box?

How to change default Target in the TinyMCE 'Insert/Edit Link' dialog box?

by Juan F -
Number of replies: 4

Just what the subject states.  I need to find out how to change the default Target in the TinyMCE 'Insert/Edit Link' dialog box to "open in new window (_blank)".

Thanks!

Average of ratings: -
In reply to Juan F

Re: How to change default Target in the TinyMCE 'Insert/Edit Link' dialog box?

by Colin Fraser -
Picture of Documentation writers Picture of Testers

I am not sure you actually can, easily that is. I suspect it has to be a hack so you will have to find the relevant code in the codebase and add in or change the default code. You will probably have to start looking for what you want in lib/editor/tinymce and somewhere there you will likely find a page called link or autolink or somesuch, depending on your version I think. Sorry I can't help more than that, but it is something I have considered in the past, but just takes up too much time for me. Good luck.

In reply to Juan F

Re: How to change default Target in the TinyMCE 'Insert/Edit Link' dialog box?

by Mauno Korpelainen -

Colin is right, there is no setting for this change but you need to edit file lib/editor/tinymce/tiny_mce/version of tinymce/plugins/advlink/js/advlink.js and there move line

    html += '<option value="_blank">' + tinyMCEPopup.getLang('advlink_dlg.target_blank') + ' (_blank)</option>';

before line

    html += '<option value="_self">' + tinyMCEPopup.getLang('advlink_dlg.target_same') + '</option>';

Save the file and test. If the change does not have effect immediately purge all caches (Site administration > Development > Purge all caches)

If you have not edited files of moodle before take a copy of that file first so that if something goes wrong in editing you have the original file available...

Average of ratings: Useful (3)
In reply to Mauno Korpelainen

Re: How to change default Target in the TinyMCE 'Insert/Edit Link' dialog box?

by Andy Chaplin -

Thanks very much!  that worked great!

In reply to Juan F

Re: How to change default Target in the TinyMCE 'Insert/Edit Link' dialog box?

by Eddy Sunderland -
Here is a short video on how that all links entered in a tinymce text editor open in a new window.  I also googled this question just today and during my search, I could not find the answer, so I tried something and it worked. So I figured I should share it. I made a short video without my ugly voice. I hope this helps even though this question was asked a long time ago.