Users should be able to choose whether to open a new window or not. This could be a block, or a setting in user profiles. Could look like this:
When I click on a link that takes me away from this site:
* Open it in the same window
o Open each link in its own window
o Open one other window for all links of this type.
Admins should have a similar dialog to set the default behavior.
If you're in need of entertainment, see a related post at http://drupal.org/node/300144 .
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | extlink-user_setting.patch | 3.51 KB | ken hawkins |
Comments
Comment #1
quicksketchHa, thanks for that reading davidlark. :)
Honestly, I think "_blank" is absolutely worthless. If I want to open a new window, I middle-click (which opens a new window/tab in every modern browser). Of course, I know many, many people do not know how to middle-click (or right-click for that matter). However, I don't find adding an option to profile page to be any more user-friendly than educating them about how to open links in new windows. If they can't figure out a middle click, they probably won't find the option in the profile page either.
So, I'm against adding this as an option in the module, as I think it's generally not going to be helpful. However, I'd like to enable you to implement this if needed on your particular site.
You can simply specify a JS variable that will toggle this behavior with something similar to the following code:
You'd need to set "external_links_new_window" variable manually some how, but this could simply be done with a profile field checkbox. You can put this code in a custom module's hook_init().
Comment #2
davidlark commentedThanks, I'll add this to the bag-o'-tricks.
Comment #3
avskip commentedDon't forget there are people that physically cannot perform a middle click (quadraplegics etc). Most of them will be using speech recognition software to access a site.
I tried a middle click on FF3 using the wheel button and both left/right mouse keys and it did nothing. Must be a setting somewhere I've missed?
I gather there won't be any change to the EL module or the 5.x version?
Skip
Comment #4
quicksketchA correction to my code, you need to pass in the second parameter of "setting" to drupal_add_js().
avskip, even speech recognition software supports different kinds of clicks. However, if that wasn't acceptable, you can turn on the option to make all external links open in a new window, or implement a custom solution by providing an option in the user profile (or elsewhere) using the above changes.
Comment #5
quicksketchMarking won't fix.
Comment #6
michelleThanks for this code. I'm sorry to see it won't be part of the module but I can make use of the code on my own site when I get to D6. I came searching to see if there was already a feature request for this because this issue has come up from users requesting it and me saying that it's generally frowned on. I already use this to add the little icon but have links set to open in the same window. Having it be a user settable option would solve the problem neatly. :)
Michelle
Comment #7
ken hawkins commentedResurrecting this thread as I've rolled some code that might achieve the original poster's intent but in a way that's more compatible with the module's spirit.
Attached patch adds a user setting that adds an option "This site offers links to other websites, would you like those links with added features?"
It is enabled by default.
Comment #8
jenlamptonSetting back to won't fix since the maintainer said he wasn't interested in supporting this feature. But thanks for the patch @Ken Hawkins, I'm sure many of us will find it useful :)
I'd also like to add that people always have the option to open any link in a new window, but adding
target="_blank"forces them to do so. An accessible alternative that will allow visitors the choice is to leave this option disabled.