<script>
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return decodeURIComponent(r[2]);
}
return null;
}
// 跳转至小程序
if(getUrlParam('target') === 'miniprogram' && !getUrlParam('path')) {
location.href='weixin://dl/business/?t=sllFuPPYHYb'; // 列表页
}
// 跳转至APP
if (getUrlParam('target') === 'app') {
var ua = navigator.userAgent.toLocaleLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
document.getElementById('wechat').style.display='block';
}
if (getUrlParam('type') === 'todo') {
location.href = 'todolist://list?scene=' + getUrlParam('sid');
} else {
location.href = 'todolist://';
}
}
</script>
这几条代码是在腾讯待办”小程序正式发布的时候邀请我体验的时候在页面中看到的。
有可能会有很多朋友会需要这个,所以就保存一下!
这段代码展示了如何通过JavaScript判断目标应用并进行相应跳转,包括小程序与APP间的切换,同时解析URL参数。
腾讯待办”小程序官方代码。&spm=1001.2101.3001.5002&articleId=120023449&d=1&t=3&u=5e89b3bf26514295b03d593b41597e42)
18万+

被折叠的 条评论
为什么被折叠?



