Create share button on Linkedin

Asked

Viewed 1,218 times

2

I am developing a Web project and in this project contains the button to share on Linkedin (customized).

I’ve worked with sharing Facebook and Twitter and so far is working normal, but I’ve never used Linkedin sharing, someone has used and can help me?

Follows code:

Share from Facebook:

Html:

<a href="" ng-click="vm.facebook(baseurl + 'conteudo/' + conteudo.slug)">
    <div class="img-circle compartilhar_icones">
        <i class="fa fa-facebook" aria-hidden="true"></i>
   </div>
</a>

JS:

vm.facebook = function (s) {
        event.preventDefault();
        window.open('https://www.facebook.com/sharer/sharer.php?u=' + s, '/&display=popup&ref=plugin', 'Pagina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=10, LEFT=10, WIDTH=770, HEIGHT=200');
    };

This code above is working, follows the code I am using for Linkedin, but is not working:

Html:

<a href="" ng-click="vm.linkedin(baseurl + 'conteudo/' + conteudo.slug, conteudo.nome)">          
  <div class="img-circle compartilhar_icones terceiro">
        <i class="fa fa-linkedin icone_linkedin" aria-hidden="true"></i>
   </div>
</a>

JS:

vm.linkedin = function (s, a){
        event.preventDefault();
        window.open('http://www.linkedin.com/shareArticle?mini=true&amp;url=' + s +';title=' + a +'', '', '550', '510', 'yes');
  };

1 answer

2


Probably how you’re using angular should change something, however one of the mistakes you gave me was:

...Event not defined...

But in angular this may not happen.

I don’t know if it’ll help, but here’s the native way':

<a href="#" onclick="linkedin(event, 'yo.com', 'meu nome');return false;">          
  <div class="img-circle compartilhar_icones terceiro">
        <i class="fa fa-linkedin icone_linkedin" aria-hidden="true">LINKDIN</i>
   </div>
</a>

JS:

linkedin = function (event, s, a){
    event.preventDefault();
    window.open('https://www.linkedin.com/cws/share?url=' +s+ '?name=' +a, 'newwindow', 'width=680, height=450');
};

EXAMPLE functional in jsfiddle

  • It has already positive and marked as the right answer, but, it would not be better in API this sharing??

  • 2

    I presented what I knew, but anyway if it is just to share it is not necessary, note that this only happens because Linkedin/facebook so want/authorize: https://developers.facebook.com/docs/plugins/share-button/. @Williamasimiliar Andean see here an example taken from here: https://jsfiddle.net/7yngdovr/1/ . As you see for this (share) it doesn’t have to go beyond this

Browser other questions tagged

You are not signed in. Login or sign up in order to post.