External links to the websites should alway open in new window. Else users will leave your website and may not return back.
Also its good to display a message box stating that they are leaving the website. Use the following method to achive this.
1. Create new file external.js
2. Put the following code in there.
$(function() {
$('a[@href^=http]').not('[@href*=yourdomain.com]')
.addClass('external-link')
.click(function() {
window.open(this.href, '_blank');
return false;
});
});
In above code replace yourdomain.com with your website domain.
3. Put the following code in your theme’s template.php
drupal_add_js('misc/external.js', 'theme');
4. Upload the external.js in your drupal 5.0 ‘s misc folder.
5. Modify your theme’s .css file to include the following class
(optional).external-link {
padding-left: 18px;
background-image: ("/files/images/extlink.png");
}
A variation to above code… to display message box on clicking of external link add the following code.
$(function() {
$('a[@href^=http]').not('[@href*=yourdomain.com]')
.addClass('external-link')
.click(function() {
confirmed = window.confirm("You are leaving this website, Click OK to continue. Click Cancel to stop.");
if (confirmed){
window.open(this.href, '_blank');
return false;
}
else
{
return false;
}
});
});