www.webdeveloper.com
Results 1 to 4 of 4

Thread: get browser resolution at runtime

  1. #1
    Join Date
    May 2012
    Posts
    2

    get browser resolution at runtime

    hi all ,

    how can i get client's browser resolution at runtime during resizing the browser ,

    i've seen a lot of code but all of them are static , they get resolution on load but w@ i want that the resolution change when the client resize browser ...

  2. #2
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,463
    Hi there Roukaya,

    and a warm welcome to these forums.

    Does this help...
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title>browser dimensions</title>
    
    <style type="text/css">
    html {
        height:100&#37;;
     }
    body {
        margin:0;
     }
    #dimensions {
        float:left;
        padding:10px;
        border:1px solid #999;
     }
    </style>
    
    <script type="text/javascript">
    
    function init(){
    
       information();
    
    onresize=function(){
       information();
      }
     }
    
    function information() {
       document.getElementById('dimensions').innerHTML=
       'browser width="'+document.body.offsetWidth+'"px"<br>'+
       'browser height="'+document.getElementsByTagName('html')[0].offsetHeight+'"px"';
     }
       window.addEventListener?
       window.addEventListener('load',init,false):
       window.attachEvent('onload',init);
    
    </script>
    
    </head>
    <body>
    
    <div id="dimensions"></div>
    
    </body>
    </html>
    
    coothead
    Last edited by coothead; 05-11-2012 at 03:40 AM. Reason: forgot body margin removal

  3. #3
    Join Date
    May 2012
    Posts
    2

    thank you

    coothead ...
    Thanks for your helpful reply ...

  4. #4
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,463
    No problem, you're very welcome.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles