How to make target=”_blank” go away

One of the things I have always disliked with Movable Type is the fact that links generated by @@ have the attribute and attribute @target=”_blank”@ appended. As the HTML-savvy will know, this tries to force the link to open in a new window when clicked.
So how do you change this? Easy, but it either requires installing the “Switch plugin.”:http://virtuelvis.com/archives/2003/03/mtswitch or editing lib/MT/Template/Context.pm from the Movable type installation. Using the Switch plugin is preferred over modifying Movable Type.


h3. Using the Switch plugin
First, install Switch. Then alter your templates. Replace any occurence of the @@ tag in your templates with this little snippet:
bc.


h3. By modifying Context.pm
Note that modifying Context.pm is not recommended, as you will have to re-apply the change every time you update Movable Type.
Look for the following line:

return sprintf qq(<a target="_blank" href="%s">%s</a>), $a->url, $name;

If you have an editor that supports jumping to a specific line number, the code is located at line 838 for both Movable Type 2.63, and 2.64. In Movable Type 3.16, this line is found at line 989.
The only thing you will have to do, is remove the offending target="_blank", so that the line looks like this:

return sprintf qq(<a href="%s">%s</a>), $a->url, $name;

A simple change that makes your comment system more user friendly.

Previous Post
Next Post

7 Comments

  1. Removing Target="_blank"e; from MT

    I despise links that create new windows. I use a browser with tabs, as does most of the rest of…

  2. A nice change IF you are not using the pop-up for comments, not a nice change if you are….
    Opening the external links in the pop-up window is NOT good. There you actually have the opposite problem/bug – at least in my version of MT – where external links in the text are tagged, but without target.

  3. Stopping MT from opening links in new windows!

    Thanks to a link at J.A.S.O.N.’s Site I have done THIS hack. No more popup windows if you click a link in the comments section, a person’s URL, anything. NONE! Be Gone, New Windows!!…

  4. Well, I took it for granted that anyone who wants to use this hack won’t use pop-ups for comments 🙂

  5. I think you’re right there, Arve. I don’t think the comment-pop is particularly useful or… well, logical, but it _just_ occurred to me that people might not know how to do it otherwise. (Given the results of your MT-Do test, actually ;>)

  6. Jon

     /  2003-07-30

    Quick question, is it a similarly simple hack to add the target=”_blank” to the url tag creator when adding a new post? So when you post a url in your blog, it appeands the target=”_blank” by default?

  7. Jon, short answer: No.
    Long answer: Even if there was a simple solution, I wouldn’t provide it, as I won’t assist people in blowing their foot off.
    Using target="_blank" to open new windows breaks one of the navigational paradigms understood by every web user there is, and it doesn’t offer you as the author any benefits: If they are intent on continuing to read your site after they’ve visited whatever you’ve linked to, they will use the back button. If they’re not going to continue reading, they’ll have to close two windows instead of one.
    If a user wants to open new windows, he or she is perfectly capable of doing so by shift-clicking on a link.
    Suggested reading: “Dive into accessibility”:http://diveintoaccessibility.org/, or more specifically, “Day 16: Not opening new windows”:http://diveintoaccessibility.org/day_16_not_opening_new_windows.html.