• Resolved ColinABQ

    (@colinabq)


    This is really just an open letter to all WordPress.org developers, and developers of themes and plugins. Sort of a miniature rant, and a plea. I hope it isn’t too misplaced.

    Would it be so terribly hard to use the html target tag in your code? I’m getting tired of seeking out and modifying all of your links to external content to make them launch in new Windows or tabs. For the most part, external content should augment a site, not replace it in the current browser tab or Window. Examples are links to wordpress.org, the developer’s personal or professional site for credit and support, the PHP and MySQL sites, and so on. Those should all launch in new browser windows or tabs. The fact that they don’t is incredibly annoying.

    I must note that the WordPress package itself has always been fraught with this problem. The blogroll and meta links. The footer links. Virtually all of the links are coded without the target=”_whatever” tag, meaning that they all clobber the page being viewed. That’s both unfair and poor coding practice.

    I ask you, all of you, to consider this. If you’re linking to anything but the site or domain that is hosting the ‘blog, PLEASE use the target tag. In the dashboard pages, in the sidebar widgets, in the footers of your themes — everywhere.

    Thanks for your patience and consideration.
    Colin

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi ColinABQ,

    As a quick solution to this, without having to modify code, you could run this Javascript in your theme:

    $(document).ready(function() {
       $('a').attr('target', '_blank');
     });

    The above script, written in jQuery, will add or modify the “target” attribute of all ‘a’ tags to being ‘_blank’. This could affect the speed and performance of your website, although it is a non-destructive and solid solution to this issue. 🙂

    Sorry Colin, but as a theme developer I disagree with you. Links should not be opened in new Window.

    Here are a couple of articles explaining why:

    Old article on Sitepoint, but still true and valid

    And here’s a good one from Smashing Magazine.

    If you are wanting to keep users on your site, then you need to give them what they want and provide great content. Opening links in a new window won’t keep them there.

    Thread Starter ColinABQ

    (@colinabq)

    Thanks for the input, I appreciate it.

    I also appreciate, and accept, some of the many reasons for it being a bad idea, a lot of the time. I just think that there enough instances of when it is a good idea, within the typical WordPress site, that it should become standard practice in most cases. Again, I think the wordpress.org and theme/plugin developer links should be considered augmenting and supporting.

    I also acknowledge that it can be tough to figure when to do it, and when not to. The keys are, what content to consider augmenting, and somehow warning the user that new tabs or Windows will be used in those cases.

    My rant wasn’t about keeping visitors at my site – my content needs to do that. My rant was about users, and me, having those links clobber whatever I was viewing or working on, and then having a heck of a time getting back there when I’m done with the augmenting or supporting information that was linked to. The wordpress.org and developer links are not, “please come read my stuff, it is much cooler than this” links, they are, “if you need help or want to know more about this, here you go.” I hope we can all understand that difference, and why at least some such links should launch in new Windows or tabs. Think of them the same way you think of “help” or “change your settings” pop-ups that some sites use.

    Regardless, I’ve softened : ) We can all be right, to a degree.

    Again, thanks.

    similar to what mattyza proposed but the below will open all links starting with http (typically your external ones!) in new window

    $(document).ready(function(){
    	$("a[@href^='http']").attr('target','_blank');
    });

    I guess one main reason for the demise of “target” is that its not valid for XHTML 1.0 strict doctypes. One of the main aims of XHTML and valid code is to make your content “platform independant”. The concept of a new window often doesnt apply to mobile web browsers.

    mattyza,

    Which file should I put this in if this is what I want to achieve?

    vooboo13,

    both mattyza and my code would be placed in a javascript file (or within script tags) if you have the jQuery javascript library installed on your site also.

    the below is an improvement from the above as it doesnt affect absolute cross links to your own site.

    $(document).ready(function(){
     $("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank");
    });
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Why aren’t developers using target tags?’ is closed to new replies.