进入页面自动执行JS
- <script type="text/javascript">
- jsBridge.ready(()=>{
- var img = "";
- for(var i=0;i<document.images.length;i++){
- if(parseInt(document.images[i].width)>100 && parseInt(document.images[i].height)>100){
- //设置页面分享图片为宽大于100,高大于100像素
- img=document.images[i].src;
- break;
- }
- }
- var shareInfo={
- title : document.title,
- link : location.href,
- imgUrl: img,
- desc : document.querySelector(".bz_message_table").textContent.replaceAll("\n","").trim().substring(0,30),
- //设置分享出去的元素内容截取,以及字数限制30
- success: function() {
- jsBridge.toast("\u5206\u4eab\u6210\u529f");
- },
- cancel: function() {
- jsBridge.toast("\u53d6\u6d88\u5206\u4eab\u6216\u5206\u4eab\u5931\u8d25");
- }
- }
- jsBridge.onMenuShareTimeline(shareInfo);
- jsBridge.onMenuShareFriend(shareInfo);
- jsBridge.onMenuShareQQ (shareInfo);
- jsBridge.onMenuShareQZone (shareInfo);
- })
- </script>
复制代码
下载jsbridge-mini.js上传服务器并引入,根据实际业务自定义JS策略,映射JS只会APP内生效!请下载APP后打开app体验!
|