Determine page type in javascript?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Hi Team!

Is there a method I can use in javascript to determine if a page is Mobile or Desktop?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 48,984 Points 20k badge 2x thumb
You can check whether "skuid.mobile" is defined --- if it is, you're in Mobile, otherwise in Desktop, e.g.

var isMobile = !!skuid.mobile;
if (isMobile) {

}
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Nice. Thanks!