注意:部分文章发布时间较长,可能存在未知因素,购买时建议在本站搜索商家名称,先充分了解商家动态。
交流:唯一投稿邮箱:hostvps@88.com。
网友 张小球的球 说:
PC站 www.mysite.com
**站 app.mysite.com
现在想实现在**端,,比如微信上面把地址www.mysite.com发给朋友,他打开,直接跳到**站 app.mysite.com
搜索到一串代码
function getMCookie(objName) {
var arrStr = document.cookie.split(&*uot;; &*uot;);
for (var i = 0; i < arrStr.len***; i++) {
var temp = arrStr[i].split(&*uot;=&*uot;);
if (temp[0] == objName) {
ret**n unescape(temp[1]);
}
}
ret**n &*uot;&*uot;;
}
function b**wserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == &*uot;ipad&*uot;;
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == &*uot;iphone os&*uot;;
var bIsMidp = sUserAgent.match(/midp/i) == &*uot;midp&*uot;;
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == &*uot;rv:1.2.3.4&*uot;;
var bIsUc = sUserAgent.match(/ucweb/i) == &*uot;ucweb&*uot;;
var bIsAnd**id = sUserAgent.match(/and**id/i) == &*uot;and**id&*uot;;
var bIsCE = sUserAgent.match(/windows ce/i) == &*uot;windows ce&*uot;;
var bIsWM = sUserAgent.match(/windows mobile/i) == &*uot;windows mobile&*uot;;
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAnd**id || bIsCE || bIsWM) {
location.href = ‘http://app.mysite.com’; //字符串内填写可访问的**版域名,例如m.xxx.com,如果没有域名可直接填写/m/index.html
}
}
var page**l = window.location.search;
if (page**l == ‘?m2w’) {
document.cookie = &*uot;m2wcookie=&*uot; + escape(&*uot;1&*uot;);
}
if (getMCookie(&*uot;m2wcookie&*uot;) != &*uot;1&*uot;) b**wserRedirect();
网友 canxiaoa 说:
应该是b**wserRedirect()方法里面没有对微信浏览器的判断
加上就行了
网友 张小球的球 说:
canxiaoa 发表于 2022-9-16 09:27
应该是b**wserRedirect()方法里面没有对微信浏览器的判断
加上就行了
网友 canxiaoa 说:
微信浏览器是Mic**Me**enger
网友 张小球的球 说:
已解决,,同时也感谢楼上大佬