Make buttons open up in new tab/window

Support Forums Cian – WP Theme Make buttons open up in new tab/window

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5433
    Reed
    Participant

    For the buttons in the Cian WP Theme, is there a way to add code to force the button to open up into a new browser tab or window? I’ve tried adding an tag instead of the url with no success.

    #5435
    CreaboxThemes
    Keymaster

    Hi Reed,

    for example for the button ‘Learn More’ in the header, you have to add the next code in the option Custom JS in the page Appearance > Theme Options > Custom Scripts:

    jQuery('.intro a.learn').on('click', function(e){ 
        e.preventDefault(); 
        var url = jQuery(this).attr('href'); 
        window.open(url, '_blank');
    });

    Regards

    #5437
    Reed
    Participant

    When I received the response via email the single quotes got converted into the equivalent hex code so when I pasted in the code, the menu stopped working on the site fore desktop browsers. However, I see now that that was a problem with the SMTP emailed delivered from the site.

    I no longer use the Learn More button, so I modified the code as shown below to work on all large buttons on the site. The if..then statement opens up anchor tags in the same window and all other links into a new browser tab. It is working very well now.

    jQuery(‘.btn-default’).on(‘click’, function(e){
    e.preventDefault();
    var url = jQuery(this).attr(‘href’);
    if (url.indexOf(‘#’) >=0) location.href =url;
    else window.open(url, ‘_blank’);

    });

    #5440
    CreaboxThemes
    Keymaster

    Hi,

    thanks for the information.

    Regards

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.