Drupal open in new window
A common request!
To open a Drupal site in a new window, you can use the following methods:
Method 1: Using the target
attribute
You can add the target
attribute to the <a>
tag that links to your Drupal site. For example:
<a rel="nofollow" target="_blank" href="https://example.com" target="_blank">Open in new window</a>
This will open the link in a new window or tab.
Method 2: Using JavaScript
You can use JavaScript to open the link in a new window. For example:
<a rel="nofollow" target="_blank" href="https://example.com" onclick="window.open(this.href, '_blank'); return false;">Open in new window</a>
This will also open the link in a new window or tab.
Method 3: Using a module
If you want to open all links to your Drupal site in a new window, you can use a module like Open in New Window
or New Window Link
. These modules provide a simple way to configure the behavior of links on your site.
Method 4: Using a theme function
You can also use a theme function to modify the behavior of links on your site. For example, you can create a custom theme function that adds the target
attribute to all links:
function mytheme_links(array $variables) {
$links = '';
foreach ($variables['links'] as $link) {
$links.= '<a rel="nofollow" target="_blank" href="'. $link['href']. '" target="_blank">'. $link['title']. '</a>';
}
return $links;
}
This theme function will open all links on your site in a new window or tab.
I hope these methods help you achieve your goal!