SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    Hull, UK
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I share to Facebook and other social media platforms?

    Hi guys,

    I'm looking to include a share icon that will allow users to share the page they are on to Facebook. I've searched around and just cannot understand the instructions for added functionality I have found on how to do this.

    Can anyone give me a hand with this please.

    I have my mark-up:
    Code:
    <ul class="socMedia">
        <li class="facebook">
            <a href="" onClick="shareFb()">
                <script>
    		function shareFb()    {
                                    	var sharer = "https://www.facebook.com/sharer/sharer.php?u=";
    					
    					window.open(sharer + location.href, 'sharer', 'width=626,height=436');
    					}
                </script>
                Facebook
                <b></b>
            </a>
        </li>
    </ul>
    This works at a basic level, however I want to add to it so the page title and a description (adding meta tags for a description on the page?) are added in the pop-up window.

    Additionally, will this work on a mobile platform?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Social media sites provide code that you can place onto your site that automatically generates all that functionality. There are also lote of tutes on how to add the code, such as this one for Facebook:

    http://searchengineland.com/how-to-p...n-a-site-42703

    I prefer not to have lots of iframes and JS on my pages, so I put together a few tips a few years ago on how to do this without them, if that's any help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •