標籤:style nbsp attr one ref sns web blog url
Web 項目中分享到微博、QQ空間等分享功能
網上有很多的模板以及代碼,但是有很多都不能分享內容,簡單的測試了下:
以新浪微博為例,文字框中的內容是title屬性,下面的連結是url屬性,如果你的連結頁面有圖片,會自動抓取圖片讓你選擇,因此,當你自己寫分享功能時需要你傳遞title和url屬性到介面連結即可。
代碼如下:
1 <script> 2 function buttonShare(url){ 3 $("#theForm").attr("action",url); 4 $("#theForm").submit(); 5 } 6 </script> 7 <body> 8 <div> 9 <a href="../front/login.htm">登入</a> 10 <form action="" id="theForm">11 <input id="title" name="title" value="測試">12 <input id="img" name="img" value="test1">13 <input id="url" name="url" value="http://image.baidu.com/">14 <span id="buttonShare" onclick="buttonShare(‘http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey‘)"><img src="http://static.youku.com/v1.0.0691/v/img/ico_Qzone.gif" /></span>15 <span id="buttonShare" onclick="buttonShare(‘http://share.renren.com/share/buttonshare.do‘)"><img src="http://static.youku.com/v1.0.0691/v/img/ico_renren.gif" /></span>16 <span id="buttonShare" onclick="buttonShare(‘http://v.t.sina.com.cn/share/share.php?appkey=2684493555‘)"><img src="http://static.youku.com/v1.0.0691/v/img/ico_sina.gif" /></span>17 <span id="buttonShare" onclick="buttonShare(‘http://www.douban.com/recommend/‘)"><img src="http://static.youku.com/v1.0.0691/v/img/ico_dou_16x16.png" /></span>18 </form>19 20 </div>21 </body>
Web 項目中分享到微博、QQ空間等分享功能