Facebook offers an easy-to-use Share dialog that you can include on your web page so people can share links through the Facebook News Feed. People open the Share dialog by clicking a link on your website, which opens a new window to a special URL on Facebook.
Here's a live example that shares a page.
Here's the HTML for the link we just provided, which shows the simplest use of the Share dialog:
<a href="https://www.facebook.com/sharer/sharer.php?u=example.org" target="_blank"> Share on Facebook </a>
location.href. That gives you code you can use on all pages:
var sharer = "https://www.facebook.com/sharer/sharer.php?u="; window.open(sharer + location.href, 'sharer', 'width=626,height=436');
Your use of the Share dialog instead of the Like button depends on the experience you want to give people who use your site. Many websites and apps use both to provide a choice, since they're both easy to implement in your code. If you're trying to decide which to use, here's the difference:
The Like button is more immediate and easier. All people need to do is to click a button, and the link immediately appears on the News Feed and timeline. They have the option of making a comment that appears along with their like, but that's not required for the action to appear on the timeline and News Feed.
The Share dialog requires a little more work from people, but also gives them more choice. When they click Share, the Share dialog requires people to add a comment and click Share Link for the action to appear in timeline and News Feed. People can also customize the title and thumbnail of the link they share. See the example Share dialog
It's important to provide an experience consistent with people's expectations. Most people are already familiar with the Like button, for example, and know what to expect when they click it.
The Share dialog provides the kind of consistency most people expect from Facebook, since it provides a familiar look and feel with an interface element that includes the Facebook icon. To be sure you're making consistent use of that element, be sure your website or app does the following: