Click here to Skip to main content
Licence 
First Posted 22 Sep 2006
Views 18,030
Bookmarked 5 times

Finding resolution of the system with javascript

By | 7 Dec 2006 | Article
tutorial to detect the resolution of the system and load appropriate page

Sample Image - top.jpg

Introduction

   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

Code

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

<script>

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

</script>

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 .

License

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

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionNope. This ain't going to work for new trends.. Check this! Pinmemberlakshmignarayanan20:22 20 May '12  
GeneralNot sure this is such a good idea PinmemberMihai Nita11:14 22 Sep '06  
GeneralRe: Not sure this is such a good idea PinmemberGarry Shutler23:10 23 Sep '06  

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

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

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