Get Screen Resolution Using Javascript | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Get Screen Resolution Using Javascript

Saturday

Find out and display a user's screen resolution with javascript.
In javascript, the screen.width and screen.height properties contain the size a visitor's monitor is set to.

This can be useful if you have a page designed for a screen resolution that is higher than some viewers may have available

The following javascript function  is used to get your system screen resolution.
<head>
 
<title>Get Screen Resolution</title>

<script type="text/javascript" language="javascript">
function scrResolution(){
        
var width=screen.width;
        var 
height screen.height;
        document.getElementById("txt_scrWidth").value=width;        document.getElementById("txt_scrHeight").value=height;
}
</script>
</head>
<body onload="scrResolution();">

  <table width="200" border="0">
     <tr>
       <td>  
 Width :
<input name="txt_scrWidth" type="text" id="txt_scrWidth" size="5" />
      </td>
     
</tr>
     
<tr>
       
<td>
           Height :
  
 <input name="txt_scrHeight" type="text" id="txt_scrHeight" size="5" />
       </
td>
     
</tr>
    
</table>
</body>
</html>
Your Screen resolution
     Width :px
     Height :px         


2 comments:

Pascal Courtois said...

you miss a "i" on ID on the height box

Unknown said...

I'm rectified. Thank you buddy.

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets