0

I have the following jquery call on my website and I would only like it to be actioned if the visitor is using a desktop device (screen size over 767px). How can this be achieved?

SCRIPT

<script>$("#sidebar").stick_in_parent();</script>
YorkieMagento
  • 336
  • 2
  • 9
  • 25

2 Answers2

2

You can check the window width, but keep in mind, there are handhelds with over 767px width. So this is not a "desktop check".

if( $(window).width() >= 767 )
    $("#sidebar").stick_in_parent();
eisbehr
  • 12,243
  • 7
  • 38
  • 63
0

Use navigator.platform to get OS Name vs. using screen size.

What is the list of possible values for navigator.platform as of today?

Community
  • 1
  • 1
Elim Garak
  • 1,728
  • 1
  • 16
  • 21