问题
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