How to open links in a new tab

In this article we will present how to open links in a new tab:

Using the Orbit Fox plugin

Step 1:

Download and Install the desired theme.

If you need help with that, check this documentation

Step 2:

Download and Install the Orbit Fox plugin.

If you need help with that, check the following documentation.

Step 3:

Go to Dashboard > Orbit Fox >General settings and make sure you have activated the Header Footer Scripts option.

Step 4:

Go to the Customizer > Header/Footer scripts, and paste the JS code snippet from the step below, according to the desired behavior:

Step 5:

Add the following code:

  •  if you want to open all links available on your site in a new tab:
// <![CDATA[
jQuery(document).ready(function($){
    $('a').each(function(){
        if( $(this).attr('href') && 0 != $(this).attr('href').indexOf('#') ) {
            $(this).attr('target', '_blank');
        }
    });
});
// ]]>
  • if you want to open an external link available on your site in a new tab
<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function($){
    $('a[href]:not([href^="ENTER YOUR SITE URL HERE"]):not([href^="#"]):not([href^="/"])').attr( 'target', '_blank' );
});
// ]]>

Make sure you replace " ENTER YOUR SITE URL HERE " with your site URL.

  •  if you want to open any particular link on your site in a new tab
<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function($){
    $('#footer .social li a').each(function(){
        if( $(this).attr('href') && 0 != $(this).attr('href').indexOf('#') ) {
            $(this).attr('target', '_blank');
        }
    });
});
// ]]>

Make sure you replace " #footer .social li a " with the particular class of which link you want to open in a new tab.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.