1. 程式人生 > >APP中分享H5連結到微信,後面被加上from=singlemessage&isappinstalled=1的解決方案

APP中分享H5連結到微信,後面被加上from=singlemessage&isappinstalled=1的解決方案

前端時間在開發APP分享H5連結到微信的功能時,一直打不開,最終發現是因為

微信分享會根據分享的不同,為原始連結拼接如下引數:

朋友圈   &from=timeline&isappinstalled=0

微信群   &from=groupmessage&isappinstalled=0

好友分享 &from=singlemessage&isappinstalled=0

在連線後加上your url?&from=singlemessage&isappinstalled=0再進行分享,即可分享成功。

同時,在對網址進行操作時,學習了下js對字串進行處理(indexof()和substring()):

var str;
var ipos;
str="123456789+abc";
ipos = str.indexOf("+");
str1=str.substring(0,ipos); //取前部分
str2=str.substring(ipos,str.length);//取後部分