• Resolved Martin Blumenfeld

    (@monkeypress)


    We set up AddToAny with Facebook, Twitter, LinkedIn, email and the copy link buttons. On desktop, Facebook, Twitter and LinkedIn all open the share in a small window. On mobile only Facebook opens in a new tab. Twitter and LinkedIn both open in the same window even though I can see the target=”_blank” in the link. Is this a glitch or is it the expected behaviour? I’m seeing this same behaviour on addtoany.com.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author micropat

    (@micropat)

    It’s intentional to avoid opening a new tab when a popular native app is probably installed and handling link sharing on mobile.

    Twitter & LinkedIn both utilize “universal links” to open their native apps on mobile during a share, so AddToAny avoids opening a new tab when sharing to those services.

    Facebook notoriously doesn’t open their native app when sharing from the web.

    Unfortunately there’s no surefire technical way to check whether a native app is installed/opened, otherwise AddToAny would use that to decide whether to open a new tab. So we optimize for the better user experience — avoiding a possibly redundant new tab — for a handful of services with popular native apps on mobile.

    Thread Starter Martin Blumenfeld

    (@monkeypress)

    Thanks for the detailed explanation @micropat! Is there a simple line of code I can add to open Twitter and LinkedIn in a new tab if my client is adamant that they open in a new tab?

    And yes Facebook is THE WORST when it comes to opening their native app.

    Plugin Author micropat

    (@micropat)

    Yes, you can use AddToAny events to change the target attribute for those buttons upon sharing.

    Settings > AddToAny > Additional JavaScript code:

    a2a_config.callbacks.push({
        share: function(data) {
            // Always open these services in a new tab.
            if ( ['Twitter', 'LinkedIn'].includes(data.service) ) {
                data.node.target = '_blank';
            }
            return data;
        }
    });
    Thread Starter Martin Blumenfeld

    (@monkeypress)

    Thank you!

    I have a similar problem but can’t get it to work with the provided example. I would like to open ALL shares in a new tab in addition to scripted urls and share titles. I have tried different approaches including just using the provided example, but none of them worked. Could you please help me how I have to extend my code so that the share open in a new tab? Thank you in advance!

    a2a_config.callbacks.push({
        share: function(share_data) {
            var new_url = '…';
    	var new_title = '… ';
    		
          if (window.location.href.indexOf("/de/") > -1) {
            new_title = '…';
            new_url= '…';
          }
    		
          if (window.location.href.indexOf("/es/") > -1) {
            new_title = '…';
            new_url= '…';
          }
    
          return {
            url: new_url,
            title: new_title,
          };
        },
    });
    • This reply was modified 2 years, 2 months ago by janado.
    • This reply was modified 2 years, 2 months ago by janado.

    Would be cool if anyone has a solution for my problem. Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Mobile Open In New Tab’ is closed to new replies.