Closed (fixed)
Project:
Links Package
Version:
master
Component:
Code: links.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Jul 2006 at 23:44 UTC
Updated:
2 Sep 2010 at 15:35 UTC
Jump to comment: Most recent file
Comments
Comment #1
figaro commentedThe attribute
target="_blank"is indeed invalid XHTML 1.0.Ideally the user has already set its browser to force behaviour regarding internal and external links.
One could insert PHP code to append
target="_blank"after every href-attribute and have links open up in a separate window if this forces behaviour not already superseded by the user, but this is not a recommended practice.A more subtle and increasingly standard way of going about it is by appending an icon indicating an external link. Wikipedia is a notable example, see "External links and further reading" at the bottom of most of its pages.
For those with Gecko based browsers there is an advanced selector which could be used; add the following to your base.css:
and place an icon indicating external links in your images folder no wider than 16pixels. Internet Explorer users will not see this icon. A sample icon is attached; copyright holder unknown.
figaro
Comment #2
syscrusher commentedI gave this issue a lot of thought, and have (for the moment at least) settled on a compromise. The ability to force "_blank" target is still present in the module, but I have added a clear warning that it is a controversial issue and that it causes invalid XHTML. This still leaves the choice with the system administrator, but advises them that there are consequences.
I like your idea of the special CSS, and may add that as a feature in the near future. Right now there is no special CSS for the Links package, so I first need to add the necessary support code to embed a reference to the CSS file in the overall Drupal output.
Scott
Comment #3
gothmog@drupal.org commentedYour compromise sounds good, as anyone can make its own choice. However I still have request:
With the latest version of the Links package posted yesterday (august 1st), under administer/settings/links, I have selected the option to 'Never' open links in new window.
When I use the weblink filter (with [weblink:45] for example), the XHTML produced still contains target="". I think in this case the target attribute should not be present at all instead of being there with no value. Only then a page would validate againt XHTML.
Thanks for your support and keep up the good work with this great module!
Comment #4
RayZ commentedTry this patch.
Comment #5
gothmog commentedThis patch works fine, thanks a lot !
Will this be integrated in the next version of the module?
Comment #6
lbjerryh commentedWhat does the patch do? My links still open in the same window under IE. Can someone clarify what this is suppose to accomplish. I use user submitted news on my site and I want the links to these stories to open in new windows to keep the user from leaving my site. How else can I accomplish this??
Comment #7
RayZ commentedAttempt to fix the HTML.
Comment #8
RayZ commentedMoved my patch to http://drupal.org/node/117108. I the original issue here has been addressed, so I'm marking it fixed.
Comment #9
(not verified) commentedComment #10
nullbarriere commentedYes, target _blank is back in HTML5, but... "User agents are encouraged to default to being configured to always reuse the current browsing context, or to at least provide that option to the user."
Anyway, how many themes will validate to HTML5 by, say, 2012?
At the moment target _blank does not validate to either XHTML 1.0 nor XHTML 1.1.
My solution:
1. I use rel="extern" instead of target="_blank".
BU Editor makes this easy by using
as 'Insert/edit link' dialog.
2. I added an eventhandler to my BODY which adds target _blank to all Links with rel="extern" attribute:
2.1 In template.php add link to javascript:
drupal_add_js(drupal_get_path('theme','my_theme').'/js/link_ext.js');2.2 Put code in link_ext.js
The HTML validates, and works in the major browsers with javascript enabled, otherwise no harm is done (links just don't open in new window).