为了账号安全,请及时绑定邮箱和手机立即绑定

指定请求桌面站点位置

指定请求桌面站点位置

POPMUISE 2022-01-20 18:42:36
如何指定“请求桌面站点”选项的位置。目前,我正在运行此代码var detector = new MobileDetect(window.navigator.userAgent);    if(detector.mobile() != null || detector.phone() != null || detector.tablet() != null){        document.location = '/mobile/login';    }它适用于登录页面,但是当我直接导航到 /mobile/signup 并单击请求桌面站点时,它会返回移动注册站点而不是桌面。另一方面,如果我转到 /desktop/signup,它会将我重定向到 /mobile/signup,这很好,我可以请求将我重定向到 /desktop/signup 的桌面站点,但如果我直接转到 /mobile/signup,我无法请求桌面站点.我目前正在使用 mobile-detect.js
查看完整描述

1 回答

?
ABOUTYOU

TA贡献1812条经验 获得超5个赞

如果您有两个不同的文件夹命名desktop,mobile然后在文件夹中的文件中添加以下脚本desktop:


var detector = new MobileDetect(window.navigator.userAgent);

    if(detector.mobile() != null || detector.phone() != null || detector.tablet() != null){

        var currentLocation = window.location.href;


       if (currentLocation.indexOf("desktop") > -1){

       document.location.href = currentLocation.replace("desktop","mobile");}

    }

构造类似的脚本并添加到文件mobile夹中存在的文件中。


查看完整回答
反对 回复 2022-01-20
  • 1 回答
  • 0 关注
  • 250 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号