Wednesday, July 1, 2009

How to get browser width and height

<html>
<head>
    <title>Get Browser Width & Height</title>
    <script languuage='javascript'>
        var BWidth,BHeigth;
        function fn() {
            if (typeof window.innerWidth != 'undefined') { // For (mozilla/netscape/opera/IE7)
                BWidth = window.innerWidth;
                BHeigth = window.innerHeight;
            }
            else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' &&
                    document.documentElement.clientWidth != 0) { // For (IE 6 with proper doctype)
                    
                    BWidth = document.documentElement.clientWidth;
                    BHeigth = document.documentElement.clientHeight;
            }
            else { //For (IE < 6)
                    BWidth = document.getElementsByTagName('body')[0].clientWidth,
                    BHeigth = document.getElementsByTagName('body')[0].clientHeight
            }
            document.title = 'Your Browser width is ' + BWidth + ' Height is' + BHeigth;
        }
    </script>
</head>
<body onresize='fn()'>
    <h3>See The Page Title While Resizing the Page (Width & Height Will Be Changing</h3>
</body>
</html>



No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.