Look at this code, it is the one that I always use to be able to populate it, you must open the console and give the option "toggle device toolbar" so that it recognizes it as mobile, otherwise it will return null.
Depends on what you mean by "mobile device". If what you want is to detect devices with low resolutions you can use the method matchMediato detect if the device has a resolution lower than one that you specify:
for (var res=2500; res>0; res-=200){
console.log('Resolución menor de ' + res + ' px: ' +
window.matchMedia('(max-width: ' + res + 'px)').matches);
}
Another technique is to check the name of the browser or agent used to see if it corresponds to one of those used on mobile devices, but this implies having to maintain a complete and updated list in your code, which can be very complicated.
Look at this code, it is the one that I always use to be able to populate it, you must open the console and give the option "toggle device toolbar" so that it recognizes it as mobile, otherwise it will return null.
Check out this post friend: https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser
It says that you could use To be able to Verify that it is a mobile device according to its operating system: Using Regex
Depends on what you mean by "mobile device". If what you want is to detect devices with low resolutions you can use the method
matchMedia
to detect if the device has a resolution lower than one that you specify:Another technique is to check the name of the browser or agent used to see if it corresponds to one of those used on mobile devices, but this implies having to maintain a complete and updated list in your code, which can be very complicated.