LinkedIn share button on webpage

4.2k views Asked by At

I have a design below which I am trying to replicate on a webpage:

enter image description here

Right now I am able to get this in the following code (also in this fiddle):

<div style="display:inline-block;vertical-align:top">
    <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.awardwinnersonly.com" data-text="Czech out the books, movies, and music that won major awards" data-via="BClayShannon">Tweet</a>
    <script>
        ! function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0],
                p = /^http:/.test(d.location) ? 'http' : 'https';
            if (!d.getElementById(id)) {
                js = d.createElement(s);
                js.id = id;
                js.src = p + '://platform.twitter.com/widgets.js';
                fjs.parentNode.insertBefore(js, fjs);
            }
        }(document, 'script', 'twitter-wjs');
    </script>
</div>
<div style="display:inline-block;vertical-align:top" class="fb-like" data-href="http://www.awardwinnersonly.com" data-send="false" data-width="450" data-show-faces="false" data-font="segoe ui">
</div>
<iframe src="https://www.facebook.com/plugins/share_button.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&layout=button&size=small&mobile_iframe=true&width=59&height=20&appId" width="59" height="20" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<g:plus action="share" href="https://www.example.com"></g:plus>

but not the LinkedIn button. I tried placing it in directly from the their code generator but for some reason it doesn't work.

The code generated is the following:

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

I am wondering, am I using the right code as highlighted above for LinkedId button to show up?

1

There are 1 answers

1
HoldOffHunger On

To simplify what the actual answer was from the given fiddle of the user...

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

However, all this does is produce a button that links to...

https://www.linkedin.com/sharing/share-offsite/?url={url}

Source: Official Microsoft LinkedIn Sharing Documentation.

I find it easier to simply use a <a href ...> link to solve this problem with an <img ...> tag. That sounds easier than importing an entire JavaScript library.