jQuery target LinkedIn share button

杀马特。学长 韩版系。学妹 提交于 2019-12-12 06:05:22

问题


I have a LinkedIn share button which I need to target with jQuery to save what content was shared etc. I've done the same with Twitter, which has an api for capturing events, but I'm having a problem with LinkedIn. Since it's not an iframe, I figured I can catch events. This is the initial code:

<li id="linkedin-share">
    <script src="//platform.linkedin.com/in.js" type="text/javascript">
        lang: en_US
    </script>
    <script type="IN/Share"></script>
</li>

So, sharing works fine, but I can't capture the click. I've managed to capture the rendered html elements in Chrome DevTool's console, but I didn't manage to capture a click. I've tried something like this:

$('<fixed parent>').on('click', '<rendered content catchable in devtools>', function(){
    console.log('captured');
});

Any ideas, is there some predefined way to do this?


回答1:


<script type="IN/Share" data-onSuccess="shared"></script>

function shared(){
     console.log('shared');
}

hacky solution

jQuery('#tester').click(function(){

    //share function here!
    IN.UI.Share().params({
    url: "http://www.example.com"
    }).place()
});

Link to docs: https://developer.linkedin.com/documents/inauth-inevent-and-inui unfortunately no event for successful share.



来源:https://stackoverflow.com/questions/27368285/jquery-target-linkedin-share-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!