Monday 22 October 2018

Browser size - Javascript

Sometimes when you are building a web page it is useful to know what the browser size is, so you check it will display correctly if it is on a desk top, lap top, tablet or mobile.

The following Javascript will put the browser client size as the title.
<html>
<head>
    <script>
        function titleIsSize() {
            document.title = "" + document.body.clientWidth + " pixels.";           
        }
    </script>
</head>
<body  onresize="titleIsSize()"  >
</body>
</html>