开发者

linkedin button dynamic rendering

开发者 https://www.devze.com 2023-03-04 06:08 出处:网络
How to render linkedin button in a dynamic way? e.g. writing the \"<script type=\'in/share\'></script>\" at runtime or after the page has finished loading. I already tested on writing it o

How to render linkedin button in a dynamic way? e.g. writing the "<script type='in/share'></script>" at runtime or after the page has finished loading. I already tested on writing it or appending it in the body tag using jquery but it doesn't work. I'll appreciate any help. th开发者_JS百科anks.


For anyone still wondering how to do this, after you load your

<script type="IN/Share"></script> //Don't forget other attributes

Just call IN.init() in your javascript and it will render the buttons.

The Developer guide does say something about using undocumented functions, but this forum post on the developer site:

https://developer.linkedin.com/forum/3-problems-share-button

As stated by Eugene O'Neill (Web Developer for LinkedIn)

1) IN.Parse() and IN.Init() are here to stay. While we do employ the policy that any undocumented methods may or may not be supported indefinitely, these two are uniquely crucial to the functionality of the framework. The amount of work it would require to remove IN.Parse()... I don't even want to think about it ;). IN.Init() is our preferred method for loading the framework asynchronously and won't be going anywhere. Feel free to use either method.


Here is how I am doing it with jQuery. I just call the linkedInShare function when I want that share widget to load.

function linkedInShare() {
    $.getScript('http://platform.linkedin.com/in.js', function() { 
      $('.something').append('<script type="IN/Share" data-counter="top"></script>');
    });
}

Hope that helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消