Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

JavaScript - How to Get Screen Resolution of User or Client Machine

Feb 25, 2013
Introduction

Here I will explain how to Get Monitor screen resolution using JavaScript or Get screen resolution of user in JavaScript.

Description:

In previous article I explained Set watermark text for textbox using JavaScript, JavaScript Set Default home page in IE, Mozilla, JavaScript add bookmark link to website and many articles relating to JavaScript, jQuery, SQL, asp.net etc. Now I will explain how to get screen resolution of user in JavaScript.

To get user screen resolution we need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Screen Resolution using JavaScript</title>
<script type="text/javascript" language="javascript">
function GetResolution(){
document.getElementById("txtWidth").value = screen.width;
document.getElementById("txtHight").value = screen.height;
}
</script>
</head>
<body onload="GetResolution();">
<table>
<tr><td align="center" colspan="2">
<b><span style="color: #990000;">Your Screen Resolution </span></b></td></tr>
<tr>
<td>Width :</td>
<td valign="middle"><input type="text" size="5" name="txtWidth" id="txtWidth">px</td>
</tr>
<tr>
<td>Height :</td>
<td valign="middle"><input type="text" size="5" name="txtHight" id="txtHight">px</td>
</tr>
</table>
</body>
</html>
Live Demo

For live demo check below of your screen resolution details

Your Screen Resolution
Width : px
Height : px

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

3 comments :

Murali Krishna.S said...

good one..

Unknown said...

Nic one

Anonymous said...

when runat="server" dont show resolution

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.