I am trying to open a new tab when a certain menu link is clicked in Drupal. One way I thought about doing is embedding a Javascript code within the content of that page. However, that does not seem to work.
Specifically, I place this code inside the HTML content of that page:
<script>
$(document).ready(function() {
var popup = window.open("about:blank", "_blank"); // the about:blank is to please Chrome, and _blank to please Firefox
popup.location = 'http://google.com';
});
</script>
Is there another way of achieving this? To clarify, I still want the menu link to navigate Drupal to whatever page is assigned to it. However, I also need a new tab to open upon the click.
window.opentakes first argument as a url and so you need to do something like this:window.open("http://somewebsite.com", "_blank")- Bubble Hacker