方法如下:

 

1.设置分享title:动态改变document.title值即可:

document.title = 'test'

  

2.设置分享图片:在页面隐藏一张尺寸大于290*290的图(图片需要容器包裹,设置容器css属性display:none即可):

<div style="display:none"><img src="share.jpg" /></div>

  

3.设置分享的链接:动态修改document.documentURI的值即可(safari下,document.documentURI为只读属性,可借助history.pushState )

//android:
document.documentURI = "http://www.navyxie.com";//经测试wechat6.3.13版本下此方法已失效,可使用同下IOS的方法自定义。
//ios:
window.history.pushState("weixin-share-url", "weixinshare", "http://www.navyxie.com");//只可设置同域链接

具体的运行原理可以看 【微信Android SDK 中的 js】 源码分析。

 

相关文章:

  • 2021-11-09
  • 2021-08-16
  • 2022-12-23
  • 2021-07-31
  • 2021-10-17
  • 2021-12-18
猜你喜欢
  • 2021-12-05
  • 2021-12-18
  • 2021-12-27
  • 2021-05-20
  • 2021-04-27
  • 2022-12-23
相关资源
相似解决方案