How to detect whether the user is using mobile, tablet or desktop and redirect them?

前端 未结 3 1131
遇见更好的自我
遇见更好的自我 2021-01-29 05:33

First off I know that a responsive site is no. 1 but at the time being that unfortunately is not an option! I also have very javascript coding skills.

I need to detect w

3条回答
  •  抹茶落季
    2021-01-29 06:10

    Your solution looks good just add a check for screen width as well which is 970px for ipad or tabs, 768px for mobile devices(smartphones) and greater than 970px for desktop version.

    As it seems you cannot use media queries as you want to redirect based on devices else media queries are the best way to do responsive design.

    You can have a look at below link as well.

    https://css-tricks.com/snippets/javascript/redirect-mobile-devices/

提交回复
热议问题