Shortly: How can I open a drupal_goto() result in a new tab?

More details:

I've got a list of news, made with Views, that can be imported from a RSS feed (big custom module, very complicated, etc, etc) or directly written by the site's editor.

When I click on a news, I access the node full view mode page and, if it is an imported news, I'm redirected to the source site with drupal_goto(source).

I want to redirect to the external source site in another tab. And I can't figure it out. I'm not even sure if that's possible with only PHP.

Thanks in advance for any help.

  • 1
    Why not detect news origin in the Views an render each one diferently (external one with blank target a, for example)?
    – sanzante
    Jul 8, 2014 at 14:52
  • Because I need to go to the internal node page first to track visited nodes. Good question btw.
    – Djouuuuh
    Jul 8, 2014 at 14:53

1 Answer 1


That isn't possible - drupal_goto() happens server-side, and you can only affect tabs/windows with client-side code.

You would need to stop using drupal_goto(), and instead insert some javascript into the page which opens the new URL in a new tab upon refresh.

Some (including myself) would also argue that you have no "right" to do this - let the user decide whether they want a new tab or not. Be careful of trying to force your will onto them. See Target Blank is Evil for a wonderfully opinionated bit of rhetoric on the matter.

  • 1
    Thanks for your quick answer. I read indeed that it was not possible on server-side and that I will need to use some JavaScript to achieve that. Unfortunately, I'm not in position to argue the "let's force or not the user to open external links in a new tab" part because it was decided so upstream and I'm only here to execute ;-) Thanks anyway for the advise!
    – Djouuuuh
    Jul 8, 2014 at 14:09
  • 1
    Ah, clients...wouldn't life be so much simpler without them? ;)
    – Clive
    Jul 8, 2014 at 14:09
  • 1
    It's worst than that, I don't have any clients. I'm working for a government company :-P
    – Djouuuuh
    Jul 8, 2014 at 14:10
  • 2
    Ouch. Run fast, run far ;)
    – Clive
    Jul 8, 2014 at 14:11

Your Answer

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

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