For external links, the overlay is adding a "_new" target attribute. The effect of this in Firefox for the first link for example is that there is one single new tab opened which is focused when you click the link. After that though, if the page has other such links, clicking those will replace the content of the previously opened tab *and* will not give focus to that tab. When you build a page output, you could use target="_blank" to always get to open a new tab and always get focus to that, but overlay-parent.js will override any such attempt. It should not.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

casey’s picture

Status: Needs review » Reviewed & tested by the community

I agree.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

I have the same 'issue', but different situation, with internal links. With external links, there are checks to not overwrite the target if one exists. However, with internal links, the target attribute is always set to "_parent". I can see the desire to keep with the idea that if the link stays on the site, then open it in the same window. At the same time, if I want to open a link in a new window with target="_blank" why should overlay trump my wishes of how to handle the link.

Anonymous’s picture

Status: Closed (fixed) » Needs review

Forgot to change status before

mErilainen’s picture

I also want to use target="_blank" for a link when user is editing content. I don't want to use the same tab/window because they will lose their changes!

Yuri’s picture

I got the same need for using target="_blank" link in the overlay.

In my case i want to create the following link in the help text of a field:
<a href="/node/add" target="_blank">Create new node</a> because I don't want the user to lose the current node edit form while creating another node. (often used when trying to reference a node that does not yet exist)

aiwata55’s picture

I have the same need as Yuri. I want to add a button with Form API to a node edit form, wrapping the button with the prefix and suffix attributes with a tag with target="_blank", to open a node addition form in a new window / tab.

olofbokedal’s picture

FileSize
686 bytes

I've also experienced this issue.

If the link is external, the target won't be overridden if it already has been set. I can't see why this couldn't be implemented for internal links as well.

Status: Needs review » Needs work

The last submitted patch, overlay_target-771036-9.patch, failed testing.

olofbokedal’s picture

FileSize
770 bytes
olofbokedal’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, overlay_target-771036-11.patch, failed testing.

olofbokedal’s picture

Status: Needs work » Needs review
FileSize
750 bytes

Ok, seriously, my apologies.

Third time's the charm!

David_Rothstein’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

I didn't test it, but the patch looks good and makes sense. Just needs a quick reroll for Drupal 8...

james.williams’s picture

I've done some limited testing on it and it works :-)

olofbokedal’s picture

FileSize
770 bytes

And here's the same patch for Drupal 8.

David_Rothstein’s picture

Status: Needs work » Reviewed & tested by the community

This looks ready to go, for both Drupal 8 and Drupal 7.

A quick way to test it is to use the Field UI to add some help text to the body field on the node form (and have the text be something like <a href="/node" target="_blank">Home</a>)... I tried that and confirmed that before the patch this link won't open in a new window, but with the patch it will.

David_Rothstein’s picture

D'oh, just realized that the test scenario I came up with is almost the exact same thing Yuri said in #7... Well, it definitely works :)

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks! Committed/pushed to 8.x. Moving to 7.x for backport.

Albert Volkman’s picture

Status: Patch (to be ported) » Needs review
FileSize
750 bytes

D7 backport.

tim.plunkett’s picture

Issue tags: +Needs backport to D7

Fixing tag.

cedwards.rei’s picture

What needs happen to get this patch committed to core??

Albert Volkman’s picture

You can help by doing a patch review!

http://drupal.org/patch/review

aspilicious’s picture

While testing this check if the overlay stays open after clearing the cache....

andyhu’s picture

#21 works for me, look forward to see this patch committed to 7.x

Amir Simantov’s picture

Hi. Patch in #21 does NOT work for me.

I am trying to add a link through Views actually, writing this code in the Header part of the view:

if (user_access('create page content')) 
  print '<strong><a target="_blank" href="node/add/page">Create new item</a></strong>&nbsp;&nbsp;';

Overlay open in the same direction.

BTW, is was better if I could add destination parameter while opening in the SAME tab, but I couldn't find any documentation of how to do in a simple PHP snippet inside a view. The naive code might be something like this:

if (user_access('create page content')) 
  print '<strong><a href="node/add/page&destination=' . current_path() . '">Create new item</a></strong>&nbsp;&nbsp;';

Any help - either for making it open in a new tab or to redirect back to the original URL - will be appreciated!

Thanks.

ar-jan’s picture

Status: Needs review » Reviewed & tested by the community

I've tested the patch in #21 with an internal link with target="_blank" in a field's help text, as described in #18 (which happens to be exactly my use case).

With the patch applied the link does open in a new window. Codewise the patch is the same as what was committed for D8, so I think this is reviewed and tested.

ar-jan’s picture

Re #27: I think you need to write the link like this:

print l('Link text', 'node/add/page', array(
  'attributes' => array(
    'title' => "Title text."),
   'query' => array(
     'destination' => current_path())));

api.drupal.org/api/drupal/includes!common.inc/function/l/7

wadmiraal’s picture

+1 For this !

Why has it not been committed yet ? The backport patch is almost a year old :-).

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -Needs backport to D7

Automatically closed -- issue fixed for 2 weeks with no activity.

Rob230’s picture

It seems that the patch only works for non-admin links, due to this condition:

if (this.isAdminLink(href))

My requirement is that the user is adding a node, and in the description of one of the fields I want to let them add another type of node, but I don't want them to lose their progress in the current form. Therefore I give it a target of _blank, but because it's an admin link, the target is ignored and it gets opened in the overlay.

I don't know if anything has changed since the patch in 7.22, because it seems to me that #7 and #18 are exactly the same requirement I have and the patch that was committed (#21) does NOT resolve it.

I managed to solve this by adding the overlay-exclude class:

<a class="overlay-exclude" target="_blank" href="node/add/thing">Add a thing</a>

This means all of the overlay-related code is skipped, and the link will simply be opened as normal, using whatever target you give it. Using the overlay-exclude class actually obviates the need for the fix in patch #21.

lunk rat’s picture

Issue summary: View changes

Rob230, thank you so much for sharing the info about overlay-exclude, it solved my problem in a simple elegant way.