facebook,twitter,pinterest的分享功能代码--js+html
生活随笔
收集整理的這篇文章主要介紹了
facebook,twitter,pinterest的分享功能代码--js+html
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前言:
??????? facebook,twitter,pinterest 雖說在國內不是如同微博,朋友圈那樣非常的盛行,但是我么的工作中涉及到國外的業務時候就必須要去研究。為此,作為一個討厭記密碼又有高度復雜密碼強迫癥的開發員,還是得把這3個社交平臺全注冊了一遍。
???????? 本文的例子非常簡單,由于只是涉及到這3個社交平臺的分享功能,所以不需要引入官方的sdk,也就不需要apikey等之類的密鑰。用 <a>和<meta>標簽就行了。
???????? 1.在你的html頁面的head標簽里加入這幾個meta標簽,關于每個標簽的含義請參考:點擊打開鏈接
???????????
?????? 2.html+js編寫分享按鈕
<div><a id="fbShare" href="javascript:window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(document.location.href),'_blank','toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=600, height=450,top=100,left=350');void(0)"><img src="../images/home/home_footer_share_facebook.png"></a><a href="javascript:window.open('http://twitter.com/home?status='+'My Item '+encodeURIComponent(document.location.href)+' '+encodeURIComponent(document.title),'_blank','toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=600, height=450,top=100,left=350');void(0)"><img src="../images/home/home_footer_share_twitter.png"></a><a href="javascript:window.open('https://www.pinterest.com/pin/create/button/?url='+encodeURIComponent(document.location.href),'_blank','toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=600, height=450,top=100,left=350');void(0)"><img src="../images/home/home_footer_share_pinterest.png"></a> </div>效果圖:
facebook測試太多次被封了。這里提醒下開發者,其實facebook的開發者平臺登錄后你會看到它有提供測試賬號。
另外如果你發現你的分享功能有問題,可以到一下官方提供的驗證站去測試下。
facebook:點擊打開鏈接 。
twitter 點擊打開鏈接
輸入你的html的url就可以,不過這就得要求你的站點可外網訪問.
以上純屬個人獨自研究成果,僅供參考,轉載請注明出處
總結
以上是生活随笔為你收集整理的facebook,twitter,pinterest的分享功能代码--js+html的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python新建一个文件目录,pytho
- 下一篇: “联通云”正式浮出水面 要讲出云计算怎样