jQuery插件添加社交分享按钮到你 网站 Socialjs

  • 源码大小:467.44KB
  • 所需积分:1积分
  • 源码编号:19JP-3307
  • 浏览次数:1141次
  • 最后更新:2023年05月29日
  • 所属栏目:社交媒体
本站默认解压密码:19jp.com 或 19jp_com

简介

社交媒体网站是获取流量的绝佳资源,但你如何让读者轻松分享你的内容?通过添加一个社交共享插件,你可以让这个过程变得更容易。

这个小巧易用的jQuery插件允许您在网站或博客上轻松创建流行社交媒体网络的社交共享按钮。它提供了一种增加流量、获得更多页面浏览量和增加订阅用户的好方法。

如何使用它:

1.在jQuery之后下载并加载socialSharing.js脚本。

  1. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  2. <script src="/path/to/socialSharing.js"></script>

2.为社交图标加载最新的字体真棒图标字体。

  1. <link rel="stylesheet" href="/path/to/font-awesome/css/all.min.css" />

3.创建一个空的DIV容器来容纳社交共享按钮。

  1. <div id="demo"></div>

4.初始化插件,在页面上生成社交分享按钮。可用的社交媒体网络:

  • 脸谱网
  • 啁啾
  • Pinterest网站
  • 领英
  • Reddit网站
  • 衣袋
  • 电子邮件
  • Whatsapp
  1. $('#demo').socialSharingPlugin({
  2.  
  3. // URL to share
  4. url: window.location.href,
  5.  
  6. // get description from meta description tag
  7. description: $('meta[name=description]').attr('content'),
  8.  
  9. // get title from title tag
  10. title: $('title').text(),
  11.  
  12. enable: ['copy', 'facebook', 'twitter', 'pinterest', 'linkedin', 'reddit', 'stumbleupon', 'pocket', 'email', 'whatsapp']
  13. })

5.可用于自定义社交共享按钮的选项。

  1. $('#demo').socialSharingPlugin({
  2.  
  3. // url to share
  4. url: '',
  5.  
  6. // page title
  7. title: '',
  8.  
  9. // page description
  10. description: '',
  11.  
  12. // image to share
  13. img: $('meta[property="og:image"]').attr('content'),
  14.  
  15. // button classes
  16. btnClass: 'btn btn-light',
  17.  
  18. // Array of social sharing links
  19. // ['copy', 'facebook', 'twitter', 'pinterest', 'linkedin', 'reddit', 'stumbleupon', 'pocket', 'email', 'whatsapp']
  20. enable: null,
  21.  
  22. // enable responsive class
  23. responsive: false,
  24. // 'left' or 'right'
  25. mobilePosition: 'left',
  26.  
  27. // copy message
  28. copyMessage: 'Copy to clipboard',
  29.  
  30. })

更新日志:

版本0.0.2(2022-11-10)

  • 使现代化

预览截图