Quite often, a user will use a service such as JSFiddle to demonstrate their point, and some answerers use it in return for a live demonstration of their code.

I'm not just talking about JSFiddle either, there are a number of services that allow links as part of a support to the OP's question or an answer.

Can these links open in a new window/tab?

I often find myself trying things in these services and testing code through a number of revisions and when I've finally solved the OP's issue, I have to use my back button to navigate through everything I've just done, just to post it back to them.

Yes, I could open in a new tab through browser functionality, but it's my own fault that I forget to do this all the time, I'm only human.

Is this possible?

  • 2
    The Top 10 Web Design Mistakes – ale Oct 3 '13 at 20:19
  • As mentioned in my comment on your question @AlEverett, this isn't supposed to apply to every link as noted in those other posts, this is specific to supporting ones such as live code links. Obviously there's the problem of identifying different types of links but with a 'known/approved' list of Live Code links, this can be manageable. – Dan Hanly Oct 3 '13 at 20:20
  • Oh? Who's going to maintain that list? – ale Oct 3 '13 at 20:21
  • 1
    $("a[href^='http://jsfiddle.net/']").attr("target","_blank") – user1228 Oct 3 '13 at 20:25
  • "Code links only" is a very arbitrary distinction. Why would you open code links and not any other link a user puts in their post? Your own logic is that code links are "supporting" links, not "navigation" links; how are sources and references not "supporting" links? Any links in a question or answer are required to be there for the purpose of supporting that question/answer. – meager Oct 3 '13 at 20:27
  • 4
    Ugh, don't play that juvenile "you mad" card. Nobody is "upset" by this. – meager Oct 3 '13 at 20:29
  • @meagar I see your point. Though, often it'll be something I take from JSFiddle and put back into the question and after 32 revisions, that's a whole lot of 'Back' clicks. If your posting a link to some supporting evidence, chances are you'll click it, then read what the page says and return to the question quickly. – Dan Hanly Oct 3 '13 at 20:29
  • Aaaw, I have an actual answer to the question! Vote to reopen! – user1228 Oct 4 '13 at 0:17

Yes, yes, a thousand times yes! Do it yourself, though.

// ==UserScript==
// @name       JSFiddle yourself in a new tab
// @namespace  http://statestreetgang.net/
// @version    0.1
// @description  Changes jsfiddle links so they open in a new tab
// @match      http://stackoverflow.com/q*
// @copyright  None! Suckmahbutt!
// ==/UserScript==

function exec(fn) {
    var script = document.createElement('script');
    script.setAttribute("type", "application/javascript");
    script.textContent = '(' + fn + ')();';

window.addEventListener("load", function () {
    exec(function () {
  • 1
    -1 Not enough jQuery – Josh Crozier Oct 3 '13 at 20:29
  • You just made this didn't you! :) – Dan Hanly Oct 3 '13 at 20:29
  • @JoshC: what are you talking about? It's all jquery! there isn't any javascript in there! – user1228 Oct 3 '13 at 20:30
  • @JoshC: ("there isn't any javascript in there!" is a joke, too) – user1228 Oct 3 '13 at 20:32
  • Tested it and it works an absolute charm! – Dan Hanly Oct 3 '13 at 20:52
  • @danielhanly.com enjoy. Should have been one line, but for that annoying hack to get jquery working. – user1228 Oct 4 '13 at 0:20
  • I'll mark yours as correct because the actual question is "Is this possible?" and you've shown me it is. Though SO doesn't support it, there is a solution. – Dan Hanly Oct 4 '13 at 12:54

No, no, a thousand times no!

Don't force me to open a new window when clicking on a link. I can Ctrl-click, middle-click, or right-click "Open in new window" if I desire.

Don't mess with the UX of basic browser functionality.

  • 1
    I understand with normal links, but my question is about Live Code links specifically, those links are used differently to normal ones, they're used to directly support the questions and answers on the site, often then referring right back to the post for an update. – Dan Hanly Oct 3 '13 at 20:15
  • 2
    @danielhanly.com Still, no. You have within you the power to open these links however you want. If you want them in a new tab, shift/ctrl/middle click and do it. You have the same ability on every website ever. Don't take away my ability to not open them in a new tab. – meager Oct 3 '13 at 20:15
  • 3
    And how do you tell them apart? – ale Oct 3 '13 at 20:15
  • 3
    We are developers, we use control click all the time :) 1+ – Josh Crozier Oct 3 '13 at 20:16
  • 3
    When I go to my cable company's website to access online video or pay my bill, I end up with 6 tabs open from their target=_blanks. Ugh! – Andrew Barber Oct 3 '13 at 20:16
  • +1. I use middle-click all the time, and when I try to open a link in the same window and it opens a new tab I rage at the heavens. If I wanted a new tab, I would've F*!($ing opened a new gd tab. – Mike G Oct 3 '13 at 20:18
  • There's a reason target=_blank was created. This would be a perfect use. Links to JSFiddle and SQLFiddle etc are used to support the page your on, not as a full navigate away. It's more of a supporting link not a navigation one – Dan Hanly Oct 3 '13 at 20:18
  • 2
    target=_blank sucks.. We will open a new tab if we want.. else there is always the back-button.. – Josh Crozier Oct 3 '13 at 20:19
  • @JoshC I was intending to answer a JS Question previously, I ended up clicking the link to debug the code and running through loads and loads of revisions. I'd have to press back for all those page re-loads just to paste my answer back to the OP. It was annoying! I could have just closed the tab and been completely more efficient. – Dan Hanly Oct 3 '13 at 20:22
  • 1
    @danielhanly.com There is no perfect use for target="_blank". It is used by website to force me to open a link in a new tab. Frankly, how I manage my tabbed browsing habits isn't the business of any website. It's completely up to the person browsing the site to choose how to open links. Do you not understand that you are already free to open up any link in a new tab yourself, by either ctrl-clicking or middle-clicking it? It costs you nothing to do so. – meager Oct 3 '13 at 20:22
  • 2
    I suggest we add popups and stuff too then, I love those - they are great for UX.. – Josh Crozier Oct 3 '13 at 20:23

Not the answer you're looking for? Browse other questions tagged .