How can I open all external links in the same new window?

Something like this...
Users navigate my website at windows A. User clicks on an external link. which loads the page in a new window, window B. User clicks on another external link and it also gets loaded in window B, and so on. No matter how many external link the user clicks, there will be only 2 windows open, one window A where my webpage will be loaded and one more window B where the external link will be loaded.

How can I accomplish this with this module?

Thank you...

Files: 
CommentFileSizeAuthor
#12 extlink-1304464-12.patch1.78 KBelachlan
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch extlink-1304464-12.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

Category:support» feature

Right now External Links module is hard-coded to open all links in a new window (a target of "_blank"). We could make an option to set the "target" attribute to a particular value which would have the effect you're describing.

I would like very much to be able to use an option to set the target name. Currently I hack the module to specify a target name.

@Mel55113

Can you please share your hack.

Thanks

Title:Open Ex. Links in a Certain WindowsAdd option to set "target" attribute

It's really pretty simple. Search for "_blank" in the file extlink.module; replace it with a target name of your choice, e.g., "mytarget". There are two occurrences, somewhere around lines 73 and 81.

If we were to add an option, Id like to give a choice rather than let the user set their own. Otherwise you open the possibility to inject html.

Mel55113 - Are you changing your target to a specific name or just to a normal target?

Link for Reference: http://www.w3schools.com/tags/att_a_target.asp

I set a specific target, what would be called a framename in the referenced page. I would like to be able to set the target uniquely for each site, e.g., for client.com I might use client-ext as the target name, for client2.com I would use client2-ext.

I'm not an expert in this area but a specified string could be cleaned in the same manner that node titles are cleaned. Or, the specified target name could be limited to simply alpha, numeric, hyphen ("-"), and underscore ("_") characters. Or, the length could be limited, e.g., maybe 8 characters. That would, I believe, prevent html injection. Also, the setting the option requires authority to alter the site configuration, something that should not be freely granted.

Hope this helps,
Mel

Title:Add option to set "target" attributeAdd option to set "target" attribute. Open all links in single window.

You are correct Mel55113.

I will look into it, unless you want to submit a patch.

Thank you! I'm not enough of a PHP programmer to create a patch :(.

I suggest we do it the same as "Display a pop-up warning when any external link is clicked."

Although this method will not work in 6.x.

That would be fine.

Actually, I don't know why it wouldn't work with Drupal 6 but I don't think it's worth the effort at this stage in D6's life.

Status:Active» Needs review
StatusFileSize
new1.78 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch extlink-1304464-12.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

First go at a patch. This should work I think.

I manually applied the patch (sorry, Windows here :(). It works!

Thanks very much,
Mel

Status:Needs review» Needs work

The last submitted patch, extlink-1304464-12.patch, failed testing.

Status:Needs work» Patch (to be ported)

Committed to GIT! Will need to port to 6.x and 8.x.

Issue summary:View changes

FYI, ever since I upgraded from 7.x-1.13 to 7.x-1.16, the module all of a sudden stopped opening external links in a new window. But all I had to do to fix this was to go to settings and just click "Save configuration" without making any changes and it started working again. YMMV.