html分享到微博,前端实现分享内容到微博、QQ、QQ空间、豆瓣等平台
分享功能可以利用插件share.js插件,也可以自己定義。只要知道各平臺的分享地址及相應的參數賦值就可以了。//第一種方法
//引入插件
//分享功能
$scope.sharePoster?=?function(platform){
//獲取需要分享的圖片地址
var?posterUrl=angular.element("#myPoster").attr("src");
if(!posterUrl){
var?layer=document.createElement("div");
layer.id="layer";
layer.innerHTML="請先上傳圖片再分享哦!"
var?style=
{
background:"#000000",
color:"#ffffff",
position:"absolute",
zIndex:10,
width:"484px",
height:"62px",
lineHeight:"61px",
textAlign:"center",
fontSize:"18px",
borderRadius:"10px",
opacity:?0.75,
left:"38%",
top:"45%"
}
for(var?i?in?style)
layer.style[i]=style[i];
if(document.getElementById("layer")==null)
{
document.body.appendChild(layer);
setTimeout("document.body.removeChild(layer)",2000)
}
return
}
var?link?=?'填入當前頁面路徑';
var?image?=?posterUrl;
var?title?=?'好好學習天天向上';
$('#shareposter').share({
url:?link,
title:?shareTitle,
description:?shareTitle,
image:?image,
sites:?['weibo','qq','qzone','douban']
});
var?shareLink?=?$('#shareposter').find('.icon-'+platform).attr('href');
window.open(shareLink,'_blank');
}
//第二種方法
$scope.sharePoster?=?function(platform){
var?link?=?'當前頁面路徑';
var?image?=?'圖片地址';
var?title?=?'好好學習天天向上';
if?(platform?==?"weibo")?{
window.open("http://v.t.sina.com.cn/share/share.php?url="?+?link?+?"&title="?+?title?+?"&content=utf8&pic="?+?image);
}
if?(platform?==?"qq")?{
window.open("https://connect.qq.com/widget/shareqq/index.html?url="?+?link?+?"&title="?+?title?+?"&pics="?+?image);
}
if?(platform?==?"qzone")?{
window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="?+?link?+?"&title="?+?title??+?"&pics="?+?image?+"&desc="?+title);
}
if?(platform?==?"douban")?{
window.open("http://www.douban.com/recommend/?url="?+?link?+?"&title="?+?title?+?"&image="?+?image);
}
}
總結
以上是生活随笔為你收集整理的html分享到微博,前端实现分享内容到微博、QQ、QQ空间、豆瓣等平台的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【51单片机快速入门指南】3.2:定时器
- 下一篇: 在宽字节环境下获取EditBox中的CS