Support » Fixing WordPress » Force target=”_blank”

  • Resolved Shyzer


    Is there any way to edit one of the core WP files so that every link created with the link quicktag button includes target=”_blank” and rel=”nofollow”? Or better yet, is there a way to make a popup box appear after the link popup box where you could check the two boxes if you wanted those two attributes?

    I know I used to be able to edit quicktags.js back in the day and make this work, but that was pre-2.0 WP. Now, I’m unable to get it to work.

    I run a blog with multiple authors and they always forget to add these two things to their links, so I have to go behind them and manually edit them in. It’d be a lot easier for me if I could make this happen automatically.

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi


    Forum Moderator

    Quicktag Extender

    Although I have to say that I think links that spawn new windows without warning the user are evil.

    Esmi, in most cases, I would agree. However I’ve done tons of research / polls with my users and they overwhelmingly want links to open in a new window. It has to do with my site material, where each post can have dozens of links to different coupons and freebies.

    Adding a new button would be an option, but is there a way to edit the pre-existing link button so that it automatically includes the two attributes? I used to do that with an older version of WordPress, but the newer version of quicktags.js is all jumbled into one giant line instead of broken up.

    You can always edit the version and then upload it to the server with the quicktags.js name.

    Or add a new quicktag tool button that can be used to insert a new window attribute on a per link basis…

    Something like:

    edButtons[edButtons.length] =
    new edButton('ed_target'
    ,'Open in New Window'
    ,' onclick="target=\'_blank\'"'
    ); // special case

    so that after you create your link in your post or page, you can insert the cursor after the href and click the new window button to insert the javascript onclick function

    I didn’t realize the file as the same as quicktags.js. Editing that and then uploading it to the server as quicktags makes perfect sense. Thanks for pointing that out.

    I’d rather use the quicktag tool button that you suggested as a backup option. My main goal would be to edit the pre-existing link quicktag button. Does anybody know while line of code I would edit? There are four instances of “href” in the quicktags file, but I’m not sure which one to add the two attributes to.

    Just for the record, I was able to get what I wanted by changing line 369 to

    edButtons[i].tagStart = '<a href="' + URL + '" target="_blank" rel="nofollow">';

    Now, when I add a link, the two attributes I wanted are inserted. I’ll have to update the file every time a new WordPress comes out, but that’s fine as I really didn’t want to run yet another plugin.

    That’s great to know…

    You should mark this topic resolved if it is.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Force target=”_blank”’ is closed to new replies.