How to detect if the user is using a laptop?

rickywh

New Member
Is there a for sure fire way to detect if a user is running in a laptop or not?

I have been working on a web application that is actually quite long heightwise compare to widthwise. When using the web app inside of a laptop running 1366x768 desktop resolution, i notice some of the output messages from my API(from the output of requests that the web app users as they are interacting with button clicks and such) are displayed near the middle of my web app which is way down the screen. On a laptop, if I were able to detect it, I could simultaneously execute some javascript to scroll down just slightly so the output message is in readable area of view port.

Anyone know a sure fire way to get the users resolution? not only that, i'd probably need a list of all the possible resolutions and which ones are laptop resolutions heh
 

ronaldroe

Super Moderator
Staff member
A list of resolutions should be easy enough to find with Google. A lot of laptops use many of the same resolutions as desktops, except for the really huge monitors, which I don't think are all that common anyway.
 

DHDdirect

New Member
If it's just certain resolution sizes you can use javascripts screen.width and screen.height such as

Code:
if ((screen.width<=1366) && (screen.height<=768)) {
 DO SOMETHING
}
 

phillihp

New Member
Is there a for sure fire way to detect if a user is running in a laptop or not?

Nope

But you can find out what User Agent information was sent to you. For example, in PHP, you would use a:
PHP:
<?php 
 echo $_SERVER['HTTP_USER_AGENT'];
 ?>

This is more for phones.

The User-Agent header of the Nokia 6230i cell phone:
Nokia6230i/2.0 (03.25) Profile/MIDP-2.0 Configuration/CLDC-1.1

The User-Agent header of the Nokia 6600 cell phone:
Nokia6600/1.0 (4.03.24) SymbianOS/6.1 Series60/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0

The User-Agent header of the Sony Ericsson T610 cell phone:
SonyEricssonT610/R501 Profile/MIDP-1.0 Configuration/CLDC-1.0

The User-Agent header of the Sony Ericsson K700i cell phone:
SonyEricssonK700i/R2AG SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1

The User-Agent header of Openwave Mobile Browser 6.2.2:
OPWV-SDK/62 UP.Browser/6.2.2.1.208 (GUI) MMP/2.0
 

leroy30

New Member
Why not just automatically scroll to the alert message anyway? You could easily work out if it's already visible on the screen or not it's just a matter of window height VS scroll top VS message offset height...

Google it lol but these properties can be found using javascript so you would be able to detect if it is not on the visible on the screen and scroll to it.

Hope that helps as a starting point!
 
Top