微博分享
/**
* @param type 'wb'=新浪微博 'tx'=腾讯微博 'qq'=空间
* @param content 分享的文字内容
* @param imgSrc 图片地址,需要传完整url ,如果没图片则留空 ‘’
* @param url 微博的来源链接,可带来回链
*/
function fShare(type, content, imgSrc, sourceUrl){
var x = 615;
var y = 505;
var at='';
var url='';
var text = encodeURIComponent(content);
var xlShareURL="http://service.weibo.com/share/share.php?title="+text+"&searchPic=false";
var qqShareURL="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title="+text+"&desc=&summary=&site=";
var txShareURL="http://share.v.t.qq.com/index.php?c=share&a=index&title="+text;
if (imgSrc)
{
xlShareURL += "&pic=" + encodeURIComponent(imgSrc);
qqShareURL += "&pic=" + encodeURIComponent(imgSrc);
txShareURL += "&pic=" + encodeURIComponent(imgSrc);
}
if (sourceUrl)
{
xlShareURL += "&url=" + encodeURIComponent(sourceUrl);
qqShareURL += "&url=" + encodeURIComponent(sourceUrl);
txShareURL += "&url=" + encodeURIComponent(sourceUrl);
}
if(type=='wb'){
url=xlShareURL;
}else if(type=='qq'){
url=qqShareURL;
}else if(type=='tx'){
url=txShareURL;
}
console.log(url);
window.open(url,"_blank", "top="+(window.screen.height-y)/2+",left="+(window.screen.width-x)/2+",width="+x+",height="+y);
}
//调用例子
//fShare("tx", "微博测试", "http://pic01.punchbox.org/sk/images/logo.png", "http://sk.coco.cn/");
判断是否微信浏览器
function isWeiXin(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.indexOf(<span style="font-family: Arial, Helvetica, sans-serif;">'micromessenger'</span>) > 0){
return true;
}else{
return false;
}
}