There is not target="_blank" added to external links.

HINT: wtf is this doing in hook_menu?

  drupal_add_js('
$(function(){
  $(\'a[@rel$="external"]\')
    .click(function(){this.target = "_blank";
    });
});', 'inline');

And why do you even need javascript?

Use the l() function's 3rd param.

Comments

cssd’s picture

I found this same issue and thanks to the 'hint' at the solution from danielb I think I have fixed it.

Well - it works for me anyway!

Hope this is useful...

The code changes are as follows;

/* remove or comment out this as can make external link in PHP below - fix

  drupal_add_js('
$(function(){
  $(\'a[@rel$="external"]\')
    .click(function(){this.target = "_blank";
    });
});', 'inline');

*/

and;

/* Make external link in PHP here rather than in javascript code - fix
** this is the old 'external link' definition - can be commented out or removed, below it is the new code - including 'target' => 'blank'

          $alink_url[] = l('alink_check\1alink_check', 
                           str_replace($links_chars, $links_chars_replace, $word['alink_url']) . 'alink_check', 
                           array(
	                           'attributes' =>array('class' => 'alink_check'.str_replace(' ', 'alink_space', $word['alink_class']).'alink_check', 
		                                            'title' => 'alink_check' . str_replace(' ', 'alink_space', check_plain($word['url_title'])) . 'alink_check'),		                          
		                       'absolute' => true
	                       )
*/

          $alink_url[] = l('alink_check\1alink_check', 
                           str_replace($links_chars, $links_chars_replace, $word['alink_url']) . 'alink_check', 
                           array(
	                           'attributes' =>array('class' => 'alink_check'.str_replace(' ', 'alink_space', $word['alink_class']).'alink_check', 
		                                            'title' => 'alink_check' . str_replace(' ', 'alink_space', check_plain($word['url_title'])) . 'alink_check',
                                                                      'target' => '_blank'),		                          
		                       'absolute' => true
	                       )

danielb’s picture

Nice work mate - I think that is the optimal solution.

greg boggs’s picture

The ext_link module is the ideal way to solve this problem.

greg boggs’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)