Click here to Skip to main content
12,701,573 members (33,419 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked

Finding resolution of the system with javascript

, 7 Dec 2006
Rate this:
Please Sign up or sign in to vote.
tutorial to detect the resolution of the system and load appropriate page

Sample Image - top.jpg


   Many times while designing websites we face the problem for selecting the resolution for the site. Here is a small tutorial on how we can solve this problem.

  In this tutorial I have used javascript to find the resolution of the client system and depending upon it we can load the page designed for the appropriate system resolution


   Here javascript is used to find the current resolution of the the client system which prints the value on the screen .


document.write ("Your screen resolution is : ");

document.write (screen.width); //prints the width of screen in pixels

  document.write ( " by ");

document.write (screen.height); //prints the height of screen in pixels


It shows the resolution of the screen as shown above.

Now ,the required page can be loaded by using simple if else statement by comparing the current screen resolution to the desired one. The command for loading a page through javascript is


location.href =  'index86.htm';  //given in the javascript file inside the if statement


The Rest of the Story

The rest is fairly simple. Just extract the files to a folder and open index.htm file .It will detect the resolution and automatically load the page correct for thsat resolution.I hope that this may help some of the beginners  in designing .


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Shailendra Sason
Software Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionNope. This ain't going to work for new trends.. Check this! Pin
lakshmignarayanan20-May-12 21:22
memberlakshmignarayanan20-May-12 21:22 
GeneralNot sure this is such a good idea Pin
Mihai Nita22-Sep-06 12:14
memberMihai Nita22-Sep-06 12:14 
GeneralRe: Not sure this is such a good idea Pin
Garry Shutler24-Sep-06 0:10
memberGarry Shutler24-Sep-06 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 7 Dec 2006
Article Copyright 2006 by Shailendra Sason
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid