-1

Is there a way to detect if the site is being viewed in mobile mode? That means the mobile version of the view itself. This should change after the user has called Request desktop version from the menu of his browser for example. That's the property I want to handle.

Paolo Forgia
  • 5,804
  • 7
  • 39
  • 55
D. Petrov
  • 1,097
  • 12
  • 22
  • 5
    This sounds like an [XY Problem](http://xyproblem.info/). What do you really care about? Why? What do you plan to use the information for? – Quentin Aug 02 '17 at 14:57
  • Hopefully this previous question answers your question :) [Here!](https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser) – Alice Yu Aug 02 '17 at 15:03
  • Temporary measure in order to advice the user to use the desktop view. You see, my website is just not layed out well yet for mobile and for now, I'd like to just tell that to the user. Something like 'Yeah, I know my site looks ugly on your phone, but you can do your job better, if you switch to desktop view'. That's all, plus I was just curious ^^ – D. Petrov Aug 02 '17 at 15:15
  • 1
    Possible duplicate of [What is the best way to detect a mobile device in jQuery?](https://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery) – EJoshuaS - Reinstate Monica Aug 02 '17 at 15:22
  • Also a possible duplicate of https://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery – EJoshuaS - Reinstate Monica Aug 02 '17 at 15:22
  • Also, please do check the tag description of the [website] tag. – EJoshuaS - Reinstate Monica Aug 02 '17 at 15:23

1 Answers1

0

my website is just not layed out well yet for mobile and for now, I'd like to just tell that to the user. Something like 'Yeah, I know my site looks ugly on your phone, but you can do your job better, if you switch to desktop view

The usual way to do this is to use media queries to check the screen size; if it's below a certain value, make the "this layout sucks" button visible.

.switchToDesktopButton {display:none}
@media screen and (max-width: 480px) {
    /* we're on mobile */
    .switchToDesktopButton {display:block}
}
Daniel Beck
  • 16,972
  • 5
  • 29
  • 49