My desire is to simply replace the code that pops links into a new window with corresponding code that pops links into a lightframe via the lightbox2 module. Later on this could be expanded to include admin options for lightbox2 and other *box modules, but first I must prove it works in the most simple way.

It seems straightforward:
1) change line 73 in extlink.module to read 'lightframe[|width:800; height:600;]' in place of _blank
2) change line 84 of extlink.js to read 'rel' in place of 'target'

Inspecting the link element in firebug shows that the rel=lightframe[|width:800; height:600;] is being appended to the links properly, but viewing the source shows that it is not there. I'm guessing it is how/when the .js is being applied that is affecting things. Whit the code as is, the target="_blank" behaves the exact same way, but works. That leads me to believe that the lightbox script is either running before that element is applied or doesn't even see it because it is added later.

Has anyone done this successfully and could point me in the right direction?

I found the following: http://drupal.org/node/442382 which pertains to doing this exact thing with the 5.x version of extlink. I believe I read somewhere that the linking strategy is different between the 5.x and 6.x versions, but I could be wrong. Can anyone confirm?

I also read that the maintainer (at least in the past) didn't want to support all of the *box modules because that would tie this module to one of them instead of keeping it open, but it seems like at least documenting an approach to do it with the popular ones would be helpful since these lightboxes are used more and more today.

Comments

Sam Straub’s picture

Title:External Links popping to lightbox2» Why is target=_blank not visible in source -or- External Links popping to lightbox2

Changed title to add more description

Sam Straub’s picture

Title:Why is target=_blank not visible in source -or- External Links popping to lightbox2» External Links not popping to lightbox2
Status:Active» Closed (works as designed)

Changed title once again... and a solution added.

This one boiled down to .js load order and the solution is to change where the extlink module loads it's .js and/or change the place where lightbox loads it's .js. In the end the simplest solution that worked on both my sandbox and dev environments was to change the load order of the lightbox .js from the header to the footer. They even provide an admin setting to do it in at: admin/settings/lightbox2/general -> Advanced Settings -> Location of Javascript (change from header to footer). In addition, I also changed line 37 of extlink.module from:
drupal_add_js($path . '/extlink.js');
to:
drupal_add_js($path . '/extlink.js', 'module', 'header');
I know module is by default, but not sure if header is too. So my advise is to make the change in lightbox2 admin first and then, if problems continue to persist, open up the module. Turning off all of the performance options and viewing source also tells a lot about the load order of the .js.

Cliff notes: lightbox2's javascript needs to load after extlink applies it's javascript.

That's it. Hopefully this can be helpful to someone else. Marking as 'by design'.

colorado’s picture

Thank you for this Sam -

I used your method to make external links open in shadowbox (using the Shadowbox module):

1) change line 73 in extlink.module to read 'shadowbox' in place of _blank
2) change line 84 of extlink.js to read 'rel' in place of 'target'

After making these changes, I had to disable the extlink module and then re-enable it. I did not have to change the order of .js files.