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.
Comment | File | Size | Author |
---|---|---|---|
#21 | overlay_target-771036-d7-21.patch | 750 bytes | Albert Volkman |
#17 | overlay_target-771036-17.patch | 770 bytes | olofbokedal |
#14 | overlay_target-771036-14.patch | 750 bytes | olofbokedal |
#11 | overlay_target-771036-11.patch | 770 bytes | olofbokedal |
#9 | overlay_target-771036-9.patch | 686 bytes | olofbokedal |
Comments
Comment #1
casey CreditAttribution: casey commentedI agree.
Comment #2
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedForgot to change status before
Comment #6
mErilainen CreditAttribution: mErilainen commentedI 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!
Comment #7
Yuri CreditAttribution: Yuri commentedI 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)Comment #8
aiwata55 CreditAttribution: aiwata55 commentedI 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.
Comment #9
olofbokedal CreditAttribution: olofbokedal commentedI'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.
Comment #11
olofbokedal CreditAttribution: olofbokedal commentedComment #12
olofbokedal CreditAttribution: olofbokedal commentedComment #14
olofbokedal CreditAttribution: olofbokedal commentedOk, seriously, my apologies.
Third time's the charm!
Comment #15
David_Rothstein CreditAttribution: David_Rothstein commentedI didn't test it, but the patch looks good and makes sense. Just needs a quick reroll for Drupal 8...
Comment #16
james.williams CreditAttribution: james.williams commentedI've done some limited testing on it and it works :-)
Comment #17
olofbokedal CreditAttribution: olofbokedal commentedAnd here's the same patch for Drupal 8.
Comment #18
David_Rothstein CreditAttribution: David_Rothstein commentedThis 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.Comment #19
David_Rothstein CreditAttribution: David_Rothstein commentedD'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 :)
Comment #20
catchThanks! Committed/pushed to 8.x. Moving to 7.x for backport.
Comment #21
Albert Volkman CreditAttribution: Albert Volkman commentedD7 backport.
Comment #22
tim.plunkettFixing tag.
Comment #23
cedwards.rei CreditAttribution: cedwards.rei commentedWhat needs happen to get this patch committed to core??
Comment #24
Albert Volkman CreditAttribution: Albert Volkman commentedYou can help by doing a patch review!
http://drupal.org/patch/review
Comment #25
aspilicious CreditAttribution: aspilicious commentedWhile testing this check if the overlay stays open after clearing the cache....
Comment #26
andyhu CreditAttribution: andyhu commented#21 works for me, look forward to see this patch committed to 7.x
Comment #27
Amir Simantov CreditAttribution: Amir Simantov commentedHi. 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:
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:
Any help - either for making it open in a new tab or to redirect back to the original URL - will be appreciated!
Thanks.
Comment #28
ar-jan CreditAttribution: ar-jan commentedI'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.
Comment #29
ar-jan CreditAttribution: ar-jan commentedRe #27: I think you need to write the link like this:
api.drupal.org/api/drupal/includes!common.inc/function/l/7
Comment #30
wadmiraal CreditAttribution: wadmiraal commented+1 For this !
Why has it not been committed yet ? The backport patch is almost a year old :-).
Comment #31
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/c9d2148
Comment #34
Rob230 CreditAttribution: Rob230 commentedIt 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: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.Comment #35
lunk rat CreditAttribution: lunk rat commentedRob230, thank you so much for sharing the info about
overlay-exclude
, it solved my problem in a simple elegant way.