First and foremost, avoid it by all means. Try to show on the small screen at least something. Try to embrace the ideas of
elegant degradation and
graceful degradation
:
https://en.wikipedia.org/wiki/Elegant_degradation[
^].
But I do understand that sometimes you cannot do a lot of too good job at once. In this case, let's properly formulate the problem. At this moment, you are not doing it right. What is the reason of not showing the full page on a mobile platform? Not enough bandwidth? Hardly. Just think about it: if this problem really exists, it can appear on the desktop as well; some desktops can use slower internet connection, they can even get it via the ad-hoc network served by a mobile device. That would be a great miss with your idea of detecting the mobile device. The whole idea is wrong.
What else? Most apparent thing is the pixel size of the screen, and, at the same time, this is the most apparent obstacle for showing more content. More exactly, only the pixel size of the windows area is important. Is the user resize it to a too small size, what's the difference if the device is desktop or not? And this is easy to detect. Use the properties
window.innerHeight
and
window.innerWidth
:
if (thereIsEnoughRoom(window.innerWidth, window.innerHeight);
showItAll();
else
showSorryComingSoon();
Isn't it logical?
—SA