View Full Version : Detecting a user's screen resolution
desrosj
12-06-2006, 10:58 AM
Hey, My sites are made to use 1024x768 resolution. I already know how to resize the window, which naturally you would use in an onload. But what if the user's screen resolution is less than 1024x768? Resizing it to 1024x768 in this case would make it too big for the screen and the scroll bars would disapear. I want to know if there is a way to detect the user's resolution, and if there is use it to resize the window the that size if it is less than 1024x768.
Desrosj
coothead
12-06-2006, 11:32 AM
Hi there desrosj,
If the user has javascript enabled then this will detect the screen dimensions...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
w=screen.width;
h=screen.height;
alert('screen width='+w+'px\n\nscreen height='+h+'px')
</script>
</head>
<body>
<div></div>
</body>
</html>
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.