Is there an easy fix that will append rel='noopener' to every link that’s set to open in a new window when using the hyperlink button in a text area field?

enter image description here

  • You can look into a CKEditor plugin to do it, or make a simple one yourself.
    – jrothafer
    Aug 22, 2019 at 19:56

1 Answer 1


I opted for an easier approach and wrote a Javascript function instead which looks for any links with an attribute of target="_blank" and adds rel="noopener".

function relnoopener() {
    const a = document.querySelectorAll('a[target="_blank"]');
    a.forEach(function(element) {
        if (!element.hasAttribute('rel')) {
            element.setAttribute('rel', 'noopener');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.