Hello, Code help

Hey, is there any chance i can open a link in a new tab while i add a command to the link?
for example like: www.link.com?newtab or something?

Thanks!

Hi @angelofgod,

Thanks for writing in.

You will need to use _blank in your href code so that it will show in new tab. for example.

<a target="_blank" href="http://www.link.com?newtab "> your Link</a>

Hope it helps.

Let us know how it goes.

Thanks.

1 Like

thanks but what if i cant insert a code but only a link?

Hi,

May I know to which element you want to add this?

You can add a class to your element then add the target attribute using jquery.

eg. Add myclass then add code below in Theme Options > JS

jQuery(function($) {
    $('.myclass').on('click', function(e){ 
       e.preventDefault(); 
       var url = $(this).attr('href'); 
       window.open(url, '_blank');
    });
});
1 Like

Hi thanks for the reply!
but i am trying to enter it in the side menu element
screenshot >> http://prntscr.com/if6sgz

Hi again,

Thank you for the screenshot, with the current setup you have it might not be possible to open a link in a new tab using a query string (e.g link . com ? newtab) but you can do it on a link’s click. To do this add the following script in your Customizer via Appearance > Customize > Custom > Edit Global Javascript

jQuery(function($) {
    $('#popmake-1279').on('click', function(e){ 
       e.preventDefault(); 
       var url = $(this).attr('href'); 
       window.open(url, '_blank');
    });
});

Hope this helps!

1 Like

Answer in secure note

Hi there,

Unfortunately we cam not be of a help here, please give us the exact URL of the page you are talking about and the screenhot of the link in the front end of the website so that we see if it is possible to select the link via Javascript and add the proper attribute.

I am sure you will understand that this is related to a 3rd party plugin and you need to follow up the case with the plugin developer if we can not help after you give us the URL of the page.

Thank you.

Hey!

The URL is the main page, its just the side menu on the left.

Hi there,

I checked the case and if you add the Javascript code below to X > Launch > Options > JS it should work:

jQuery('.wp-side-menu a.wp-side-menu-item').attr('target', '_blank');

I added the code for you.

Thank you.

1 Like

Much thanks!!!

You’re welcome.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.