You are here

jQuery ShareThis Plugin in ShareThis 6

ShareThis is a web service that provides an easy way of sharing data. The jQuery ShareThis plugin uses jQuery to stick the ShareThis widget on any element. Using this also means that the ShareThis API will be loaded after the whole page has been rendered, making the page seem to load faster.

ShareThis

Usage

$('a.sharethis').sharethis();

Calling the jQuery sharethis() function will create a ShareThis widget on the given object. It will use the href and title tags to create the widget.

Advanced

Note that you can pass the ShareThis API URL from ShareThis's Get the Button for the sharethis() call, and the given settings will be set.

$('a.sharethis').sharethis('http://w.sharethis.com/button/sharethis.js#headerTitle=ShareThis%20Widget');

File

sharethis/jquery.sharethis.html
View source
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>jQuery ShareThis Plugin</title>

  <!--
    Reference jQuery from the Google CDN.
  -->
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

  <!--
    Reference the jQuery ShareThis plugin.
  -->
  <script src="jquery.sharethis.js" type="text/javascript"></script>

  <!--
   Some styling for the ShareThis icon.
  -->
  <style type="text/css">
    a.sharethis { text-decoration: none;}
    img { border: 0px; }
  </style>
</head>
<body>
  <h1>jQuery ShareThis Plugin</h1>
  <p><a href="http://sharethis.com">ShareThis</a> is a web service that provides an easy way of sharing data. The jQuery ShareThis plugin uses jQuery to stick the ShareThis widget on any element. Using this also means that the ShareThis API will be loaded after the whole page has been rendered, making the page seem to load faster.</p>

  <!--
    Reference the jQuery ShareThis plugin.
  -->
  <p><a href="http://drupal.org/project/sharethis" class="sharethis" title="The Drupal ShareThis Module"><img src="jquery.sharethis.png" /> ShareThis</a></p>

  <h2>Usage</h2>
  <pre>$('a.sharethis').sharethis();</pre>
  <p>Calling the jQuery sharethis() function will create a ShareThis widget on the given object. It will use the href and title tags to create the widget.</p>

  <!--
    Create the ShareThis widget.
    It uses the HREF and TITLE from the link to create the widget.
  -->
  <script type="text/javascript">
    $('a.sharethis').sharethis();
  </script>

  <h2>Advanced</h2>
  <p>Note that you can pass the ShareThis API URL from <a href="http://sharethis.com/publishers/getbutton/">ShareThis's Get the Button</a> for the sharethis() call, and the given settings will be set.</p>
  <pre>$('a.sharethis').sharethis('http://w.sharethis.com/button/sharethis.js#headerTitle=ShareThis%20Widget');</pre>

</body>
</html>