manoj.ms89
By default, there’s no option to do that, either in WordPress or in HTML, but we can make use of JavaScript to get this functionality.
Solution consists of two parts, we need to add some JS to open the link in new window instead of tab, then we need to make sure our JS knows which link to open in new window instead of tab.
For the later, we can add a class, lets say, open-in-new-window to the menu item.
Now we need to add the JS. You can add that in your existing child theme or a custom plugin you might be using on your site. Here’s the code :
jQuery( document ).ready( function () {
jQuery( 'a.open-in-new-window' ).click( function () {
var width = window.innerWidth;
var height = width * window.innerHeight / window.innerWidth;
window.open( this.href, 'newwindow', 'width=' + width + ', height=' + height + ', top=' + ( ( window.innerHeight - height ) / 2 ) + ', left=' + ( ( window.innerWidth - width ) / 2 ) );
} );
} );
Assuming you’re already using jQuery in your theme