js社交相关代码

微博分享


/**
 * @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;
    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值