Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1373857
    Naturalife
    Participant

    Hello,

    I was wondering if there was any way to open all external links in a new tab using this theme.

    Any help would be hugely appreciated.

    Thank you so much.

    website: http://naturalife.org

    #1374021
    Rahul
    Moderator

    Hi There,

    Thanks for writing in!

    To open posts in a new tab automatically, please add the following JS code in the customizer, Appearance > Customize > Custom > Javascript:

    (function($){
      $('.entry-title a').attr('target', '_blank');
    })(jQuery);
    

    Let us know how it goes.

    Thanks.

    #1391246
    Naturalife
    Participant

    Worked like a charm! Thank you

    #1391388
    Prasant Rai
    Moderator

    You are most welcome. 🙂

    #1402048
    Tim
    Participant

    The solution above did not work for me, but I found the following snippet, which worked perfectly:

    /*Open all external links in a new window*/
    jQuery(document).ready(function($) {
        $('a').not('[href*="mailto:"]').each(function () {
    		var isInternalLink = new RegExp('/' + window.location.host + '/');
    		if ( ! isInternalLink.test(this.href) ) {
    			$(this).attr('target', '_blank');
    		}
    	});
    });

    Sharing so that it might help someone else.

    #1402140
    Joao
    Moderator

    Hi Timothy,

    Thanks for your input for the community.

    Cheers

  • <script> jQuery(function($){ $("#no-reply-1373857 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>