js實(shí)現(xiàn)通用的微信分享組件示例
一、可定義的信息
1、分享時(shí)顯示的LOGO;
2、分享LOGO的寬度;
3、分享LOGO的高度;
4、分享出去顯示的標(biāo)題(默認(rèn)調(diào)用網(wǎng)頁(yè)標(biāo)題);
5、分享出去顯示的描述(默認(rèn)調(diào)用網(wǎng)頁(yè)標(biāo)題);
6、分享鏈接(默認(rèn)為當(dāng)前頁(yè)面的URL)。
7、分享微信的APPID(一般為空)。
二、使用方法
1、引入微信分享組件js:
/*******************************
* Author:Mr.Think
* Description:微信分享通用代碼
* 使用方法:_WXShare('分享顯示的LOGO','LOGO寬度','LOGO高度','分享標(biāo)題','分享描述','分享鏈接','微信APPID(一般不用填)');
*******************************/
function _WXShare(img,width,height,title,desc,url,appid){
//初始化參數(shù)
img=img||'http://a.zhixun.in/plug/img/ico-share.png';
width=width||100;
height=height||100;
title=title||document.title;
desc=desc||document.title;
url=url||document.location.href;
appid=appid||'';
//微信內(nèi)置方法
function _ShareFriend() {
WeixinJSBridge.invoke('sendAppMessage',{
'appid': appid,
'img_url': img,
'img_width': width,
'img_height': height,
'link': url,
'desc': desc,
'title': title
}, function(res){
_report('send_msg', res.err_msg);
})
}
function _ShareTL() {
WeixinJSBridge.invoke('shareTimeline',{
'img_url': img,
'img_width': width,
'img_height': height,
'link': url,
'desc': desc,
'title': title
}, function(res) {
_report('timeline', res.err_msg);
});
}
function _ShareWB() {
WeixinJSBridge.invoke('shareWeibo',{
'content': desc,
'url': url,
}, function(res) {
_report('weibo', res.err_msg);
});
}
// 當(dāng)微信內(nèi)置瀏覽器初始化后會(huì)觸發(fā)WeixinJSBridgeReady事件。
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
// 發(fā)送給好友
WeixinJSBridge.on('menu:share:appmessage', function(argv){
_ShareFriend();
});
// 分享到朋友圈
WeixinJSBridge.on('menu:share:timeline', function(argv){
_ShareTL();
});
// 分享到微博
WeixinJSBridge.on('menu:share:weibo', function(argv){
_ShareWB();
});
}, false);
}
- js實(shí)現(xiàn)微信分享代碼
- VueJs單頁(yè)應(yīng)用實(shí)現(xiàn)微信網(wǎng)頁(yè)授權(quán)及微信分享功能示例
- javascript實(shí)現(xiàn)修改微信分享的標(biāo)題內(nèi)容等
- JS中靜態(tài)頁(yè)面實(shí)現(xiàn)微信分享功能
- Javascript 實(shí)現(xiàn)微信分享(QQ、朋友圈、分享給朋友)
- js微信分享實(shí)現(xiàn)代碼
- javascript實(shí)現(xiàn)微信分享
- 淺談微信JS-SDK 微信分享接口開(kāi)發(fā)(介紹版)
- js微信分享API
- 手機(jī)瀏覽器喚起微信分享(JS)
相關(guān)文章
javascript創(chuàng)建對(duì)象、對(duì)象繼承的實(shí)用方式詳解
JavaScript中的對(duì)象是基于原型的。原型是對(duì)象的基礎(chǔ),它定義并實(shí)現(xiàn)了一個(gè)新對(duì)象所必須包含的成員列表,并被所有同類對(duì)象實(shí)例所共享。與其他語(yǔ)言中類的概念相比,原型更像是類的靜態(tài)成員。本文著重給大家介紹javascript創(chuàng)建對(duì)象、對(duì)象繼承的實(shí)用方式2016-03-03在JavaScript中處理字符串之fontcolor()方法的使用
這篇文章主要介紹了在JavaScript中處理字符串之fontcolor()方法的使用,是JS入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-06-06用javascript自動(dòng)顯示最后更新時(shí)間
用javascript自動(dòng)顯示最后更新時(shí)間...2007-03-03