为系统自带分享按钮定义页面分享内容
可以适用于原生标题栏上分享按钮;浮动功能面板分享按钮
指定页面分享图片宽高
指定分享内容和字数
指定分享URL为当前页面链接
- <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){
- img=document.images[i].src;
- break;
- }
- }
- var shareInfo={
- title : document.title,
- link : location.href,
- imgUrl: img,
- desc : document.querySelector(".内容指定元素").textContent.replaceAll("\n","").trim().substring(0,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>
复制代码
|