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 ();