This article mainly introduces the sharing common components used to define the sharing information for Browsing webpages in a browser. If you need them, refer
I. definable Information
1. LOGO displayed during sharing;
2. Share the LOGO width;
3. Share the LOGO height;
4. Share the title displayed on the webpage (the webpage title is called by default );
5. Share the displayed description (by default, the webpage title is called );
6. Share a link (the URL of the current page by default ).
7. Share the APPID (usually empty ).
Ii. Usage
1. Introduce the sharing component js:
The Code is as follows:
/*******************************
* Author: Mr. Think
* Description: share common code.
* Usage: _ WXShare ('share the LOGO ', 'logo width', 'logo high', 'share title', 'share description', 'share link ', 'appid (not required )');
*******************************/
Function _ WXShare (img, width, height, title, desc, url, appid ){
// Initialization parameters
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 | '';
// Built-in method
Function _ reset friend (){
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 ('effectimeline ',{
'Img _ url': img,
'Img _ width': width,
'Img _ height': height,
'Link': url,
'Desc': desc,
'Title': title
}, Function (res ){
_ Report ('timeline', res. err_msg );
});
}
Function _ revoke WB (){
WeixinJSBridge. invoke ('invalid weio ',{
'Content': desc,
'Url': url,
}, Function (res ){
_ Report ('weibo ', res. err_msg );
});
}
// When the built-in browser is initialized, The WeixinJSBridgeReady event is triggered.
Document. addEventListener ('weixinjsbridgeready', function onBridgeReady (){
// Send it to a friend
WeixinJSBridge. on ('menu: share: appmessage', function (argv ){
_ Begin friend ();
});
// Share with your friends
WeixinJSBridge. on ('menu: share: timeline ', function (argv ){
_ ShareTL ();
});
// Share on Weibo
WeixinJSBridge. on ('menu: share: Weaver ', function (argv ){
_ Required WB ();
});
}, False );
}