Feature #3801

Links to external pages should get a target="_blank" attribute

Added by Roderik van der Veer over 9 years ago. Updated about 3 years ago.

Status:ClosedStart date:2009-09-01
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Text formatting
Target version:-
Resolution:Duplicate

Description

When using links in the descriptions of bugs (happens a lot if you use redmine for web projects), the automatic link replacer should add a target="_blank" to these links. Because while you want to go and view these links, you still need the tickets and redmine system as well.


Related issues

Duplicates Redmine - Feature #1151: Open Links in New-Window New 2008-05-01

History

#1 Updated by Ewan Makepeace over 9 years ago

I dont get it - surely you just ctrl-click (or whatever your browser needs) to open all the linked pages in new tabs? I think explictly setting the target could have nasty side effects from time to time, and give me no real convenience?

#2 Updated by Roderik van der Veer over 9 years ago

My problem with external links is that while following the links from a redmine ticket, the context of the ticket is gone unless you press your back button a few times, or you enter the redmine url again and look for the ticket again.

While you might be correct to assume there might be some other consequences a lot of intermediate solutions are available, see this acticle: http://www.sitepoint.com/article/beware-opening-links-new-window/

The icons is also the way sites like wikipedia handle external links.

#3 Updated by Anonymous over 9 years ago

+1 on _blank ( or config option )

#4 Updated by Adam Piotr Żochowski over 9 years ago

Ctrl-click doesn't work on all browsers:
  • Chrome : ctrl-click
  • Firefox : ctrl-click
  • Opera : ctrl-shift-click
  • IE : shift-click

Alternatively, there is also the middle-click.

No self respecting site, that I know, does this to its users. Please refer to see how wikipedia, google, slashdot and even smaller sites like digg/reddit work. Neither open new windows.

#5 Updated by Henrik Ammer over 9 years ago

Roderik van der Veer wrote:

My problem with external links is that while following the links from a redmine ticket, the context of the ticket is gone unless you press your back button a few times, or you enter the redmine url again and look for the ticket again.

While you might be correct to assume there might be some other consequences a lot of intermediate solutions are available, see this acticle: http://www.sitepoint.com/article/beware-opening-links-new-window/

The icons is also the way sites like wikipedia handle external links.

I agree that PDFs etc that should be downloaded should open in a new window but with obfuscated URLs, how do we tell them apart? For instance, a bit.ly link can link to a PDF or a webpage and there is no way of knowing.

Anything else is up to the user to choose. If I want a new window (or rather tab for that matter) I middleclick in Firefox and I have it, if I wish to leave the site and read on I just click the link. Don't force me to see new windows/tabs when I click external links if I don't want to, it's just bad practice and will get the users blood boiling.

My $.02

#6 Updated by Olivier Farlotti over 8 years ago

While i understand you, the fact is that is damageable for users that don't want _blank link since they can't get the original behavior of the link back.

More over it's not considered as a good practice by W3C for accessibility et usability purpose

#7 Updated by Matt N over 7 years ago

+1 for allowing a config. While users can do extra clicks, it's not necessarily convenient. Besides, Redmine makes uses of this in things like help.

Under Chrome:
Help->Text Formatting : brings up a popup
Help->Text Formatting->More Information : brings up a new tab from the popup

#8 Updated by Mischa The Evil over 7 years ago

Matt N wrote:

[...] Besides, Redmine makes uses of this in things like help.

Under Chrome:
  • Help->Text Formatting : brings up a popup
  • Help->Text Formatting->More Information : brings up a new tab from the popup

True, but the textformatting "help" link is different since there is a specific need to open these links in other popups/tabs. You can't compare these two things IMHO.

#9 Updated by Matt N over 7 years ago

Agreed, but we're also making (incorrect) presumptions, by not allowing these action, that folks won't have specific needs themselves to open their links in other tabs.

#10 Updated by Rob C almost 7 years ago

I would really like this feature. External links should open in a new window (or best case it would be a setting I could enable).

#11 Updated by Filou Centrinov about 6 years ago

+1

#12 Updated by Daniel Felix about 6 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

Closing this as duplicate of #1151.

#13 Updated by Filou Centrinov about 6 years ago

Fix:

/lib/redcloth3.rb

- external = (url =~ /^https?:\/\//) ? ' class="external"' : ''
+ external = (url =~ /^https?:\/\//) ? ' class="external" target="_blank"' : ''

/lib/redmine/wiki_formatatting.rb

- %(#{leading}<a class="external" href="#{ERB::Util.html_escape href}">#{ERB::Util.html_escape content}</a>#{post}).html_safe
+ %(#{leading}<a class="external" target="_blank" href="#{ERB::Util.html_escape href}">#{ERB::Util.html_escape content}</a>#{post}).html_safe

Add this to your Stylesheets:
/public/stylesheets/application.css

a.external {
  background-position: 0% 60%;
  background-repeat: no-repeat;
  padding-left: 12px;
  background-image: url(../images/external.png);
}

#14 Updated by Filou Centrinov almost 6 years ago

Alternative without changing system:
Add the following code at the end of /public/javascripts/application.js

function addTargetExternalLinks() {
  $('a.external').each(function() {
    $(this).attr('target','_blank');
  });
}

$(document).ready(addTargetExternalLinks);

#15 Updated by Samuel Suther over 4 years ago

This is still not implemented in the Core till now.
Would be gread if Redmine had this feature out of the Box!!!

#16 Updated by Miroslav Zaťko almost 4 years ago

+1
Would be great if Redmine had this feature!

#17 Updated by Viktor Neufeld over 3 years ago

For other people who find this.

Debian 7, Redmine 1.4.4

Similar as Filou Centrinov mentioned above, add this at the end of your /public/javascripts/application.js

function addTargetExternalLinks() {
  $$('.external').each(function(link) {
    link.setAttribute('target','_blank');
  });
}

Event.observe(window, 'load', addTargetExternalLinks);

#18 Updated by Anthony Cartmell about 3 years ago

For Redmine 3.1.3, add this to the bottom of /public/javascripts/application.js:

function addTargetExternalLinks() {
  $('.external').attr("target", "_blank");
}

$(document).ready(addTargetExternalLinks);

See also #1151

Also available in: Atom PDF