Pages

Monday, August 17, 2009

Get the Screen size using JavaScript

 

<html
xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        function showScreenData() {
            document.getElementById("lblScreenDetails").innerText =
           "Total Height: " + screen.height
           +" Total Width: " + screen.width
           +" Available Height: " + screen.availHeight
           +" Available Width: " + screen.availWidth
           +" Available Pixel Depth : " + screen.pixelDepth
           +" Available Color Depth : " + screen.colorDepth
           +" Buffer Depth : " + screen.bufferDepth;
            return false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <asp:Button ID="btnScreenData" runat="server" Text="Get Screen Details" OnClientClick="return showScreenData()" />
    <br />
    <asp:Label ID="lblScreenDetails" runat="server" Text="Label"></asp:Label>
    </form>
</body>
</html>

-Venky

0 comments: