JS implementation of the common micro-trust component sample

Source: Internet
Author: User

  This article mainly introduces the common components of micro-letter sharing, used in micro-trust browser to browse the Web page of the definition of sharing information, need friends can refer to the following

I. Customizable information   1, share the logo displayed, 2, share the width of the logo, 3, share the height of the logo, 4, share out the title of the display (default call page title); 5, share out the description of the display (default call page title); 6, share links ( Defaults to the URL of the current page). 7. Share the AppID of micro-letters (generally empty).   II, using methods   1, the introduction of micro-letter sharing components JS: Code as follows:/*******************************  * Author:Mr.Think  * Description: Micro-letter sharing common code  * use method: _wxshare (' share display logo ', ' logo width ', ' logo height ', ' share title ', ' Share description ', ' Share link ', ' Micro-letter AppID (general not fill) ');  *******************************/function _wxshare (img,width,height,title,desc,url,appid) {   / Initialization parameters     Img=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| | ';    /micro-letter built-in method     function _sharefriend () {        Weixinjsbridge.invoke (' sendappm Essage ', {              ' AppID ': AppID,             &NBSP ; ' img_url ': IMG,               ' img_width ': width,               ' img_height ': height,               ' link ': URL,         &N Bsp     ' desc ': desc,               ' title ': Title         &N Bsp    }, function (res) {              _report   (' send_msg ', res.err_msg);          })    }     function _sharetl () {        Weix Injsbridge.invoke (' Sharetimeline ', {              ' Img_url ': IMG,               ' img_width ': width,             ' img_height ': height, &nb Sp             ' link ': URL,               ' desc ': desc, &nbs P            ' title ': Title              }, function (res) {&nbs P             _report (' Timeline ', res.err_msg);              });    }     function _sharewb () {        Weixinjsbridge.invoke (' Shareweibo ', {&nbsp ;             ' content ': desc,               ' url ': URL, &n Bsp             {}, function (res) {              _report (' Wei Bo ', res.err_msg);              });    }    //The Weixinjsbridgeready event is triggered when the micro-mail built-in browser is initialized.     Document.addeventlistener (' Weixinjsbridgeready ', function Onbridgeready () {        & nbsp  //Send to friends             Weixinjsbridge.on (' Menu:share:appmessage ', function (argv) {                _sharefriend ()          });              //share to Friend Circle             Weixinjsbridge.on (' m Enu:share:timeline ', function (argv) {                _sharetl ()     &NB Sp          });              //share to micro-blog             Weixinjsbridge.on (' Men U:share:weibo ', function (argv) {                _SHAREWB ();       & nbsp    });    }, FALSE); }  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.