1. 程式人生 > >share.js分享 JQ第三方分享外掛 可自定義連結、標題

share.js分享 JQ第三方分享外掛 可自定義連結、標題

1、直接使用以下程式碼
2、載入附件中的js、css
3、定義要分享的連結

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>分享</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui" />
    <meta name="apple-mobile-web-app-capable"
content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta name="format-detection" content="telephone=no, email=no" /> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script src="layer_mobile/layer.js"
>
</script> <!-- share css & js --> <link rel="stylesheet" href="share/css/share.min.css"> <script src="share/js/social-share.min.js"></script> <style type="text/css"> .social-share .social-share-icon{width: 50px !important;height: 50px !important
;line-height: 50px !important;margin-left: 0.5rem;}
.share_title{color:#c01414;text-align: center;font-size: 0.38rem;line-height: 1rem;}
</style> </head> <body> <button onclick="do_share();">分享</button> <div id="share_box" style="display:none;"> <h1 class="share_title">分享到</h1> <div class="social-share" data-initialized="true" style="text-align: center;" data-url="http://www.baidu.com?(要分享的連結)" data-title="要分享的標題(可選)"> <a href="#" class="social-share-icon icon-weibo"></a> <a href="#" class="social-share-icon icon-wechat"></a> <a href="#" class="social-share-icon icon-qq"></a> <a href="#" class="social-share-icon icon-qzone"></a> </div> </div> <script type="text/javascript"> //彈出頁面層 function do_share(){ layer.open({ type: 1 ,content: $('#share_box').html() ,anim: 'up' ,style: 'position:fixed; bottom:0; left:0; width: 100%; padding:10px 0; border:none;' }); } </script> </body> </html>

自定義配置:

data-url : ”, // 網址,預設使用 window.location.href
data-source : ”, // 來源(QQ空間會用到), 預設讀取head標籤:
data-title : ”, // 標題,預設讀取 document.title 或者
data-origin : ”, // 分享 @ 相關 twitter 賬號
data-description : ”, // 描述, 預設讀取head標籤:
data-image : ”, // 圖片, 預設取網頁中第一個img標籤