Common js event accumulation and js event accumulation in WeChat

Source: Internet
Author: User

Common js event accumulation and js event Accumulation

1. Slide the left and right sides of the webpage image set to view the image, as shown in the following example:

Jjs Effect

Var pictures = [];

Angular. forEach (pitctures, function (k, I ){
Pictures [I] = k. imgPath;
});

$ Scope. previewPics = function (currentUrl ){
If (typeof window. WeixinJSBridge! = 'Undefined '){
// View image sets
WeixinJSBridge. invoke ('imagepreview ',{
'Current': currentUrl, // current address
'Urls': pictures // Group
});
} Else {
Alert ("please check in", null, function (){});
}
}

Page elements:

<Div class = "infoPics">
<Div class = "picImg" ng-repeat = "picture in info. infoContent. pitctures">

</Div>
</Div>

 

2. window close event. The example is as follows:

WeixinJSBridge. invoke ('closewindow', {}, function (res ){
// Alert (res. err_msg );
});

 

3. Share web links to friends, friends, and Weibo

Var lineLink = 'HTTP ://../..',

ImgUrl = 'HTTP ://../..',

Subtitle Title = 'page title ',

DescContent = 'content introduction ',

Appid = '';

// Determine if Javascript is supported

If (typeof WeixinJsBridge = 'undefined '){

If (document. addEventListener ){

Document. addEventListener ('weixinjsbridgeready', onBridgeReady, false );

} Else if (document. attachEvent ){

Document. attachEvent ('weixinjsbridgeready', onBridgeReady );

Document. attachEvent ('onweixinjsbridgeready', onBridgeReady );

}

} Else {

OnBridgeReady ();

}

 

Function onBridgeReady (){

WeixinJsBridgeReady. on ('menu: share: appmessage', wx_shareFriend); // share a friend

WeixinJsBridgeReady. on ('menu: share: timeline ', wx_javastimeline); // share it with your friends

WeixinJsBridgeReady. on ('menu: share: weibo ', wx_w.weibo); // share a friend

}

 

Function wx_javasfriend (){

WeixinJsBridge. invoke ('sendappmessage ',{

"Appid": appid,

"Img_url": imgurl,

"Img_width": '20140901 ',

"Img_height": '20140901 ',

"Link": lineLink,

"Desc": descContent,

"Title": Your title

}, Function (res ){

Console. log (res. err_msg );

}

});

}

 

Function wx_effectimeline (){

WeixinJsBridge. invoke ('sendtimeline ',{

"Appid": appid,

"Img_url": imgurl,

"Img_width": '20140901 ',

"Img_height": '20140901 ',

"Link": lineLink,

"Desc": descContent,

"Title": Your title

}, Function (res ){

Console. log (res. err_msg );

}

})

}

 

Function wx_shareWeibo (){

WeixinJsBridge. invoke ('sendweio ',{

"Appid": appid,

"Img_url": imgurl,

"Img_width": '20140901 ',

"Img_height": '20140901 ',

"Link": lineLink,

"Desc": descContent,

"Title": Your title

}, Function (res ){

Console. log (res. err_msg );

}

})

}

4. Hide the button in the upper-right corner of the webpage

WeixinJsBridge. call ('hideoptionmenu ');

 

5. Hide the navigation bar at the bottom of the webpage

WeixinJsBridge. call ('hidetoolbar ');

 

6. Obtain the current network connection type:

WeixinJsBridge. invoke ('getnetworktype', {}, function (e ){

Console. log (e. err_msg );

})

 

7. Prohibit users from sharing

WeixinJsBridge. invoke ('disabledshare', {}, function (e ){

})

 

8. Determine whether to enable it in the built-in browser

// True or false

Var flag = WeixinApi. openInWeixin ();

 

Related Article

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.