vForums Support > Programming & Coding :: Code Requests & Support :: > Window height/width code

Window height/width code - Posted By Aiken (ionfortuna) on 7th Jan 10 at 6:14pm
Code:
 
  1. <script type="text/javascript">
  2.  
  3.     function Size(SType)
  4.  
  5.         var TypeSize;
  6.  
  7.         switch (SType){
  8.     
  9.             case x:
  10.     
  11.                 if (window.innerWidth){
  12.                     TypeSize = window.innerWidth
  13.                 } else if (document.all){
  14.                     TypeSize = document.body.clientWidth
  15.                 }
  16.  
  17.                 break;
  18.  
  19.             case y:
  20.     
  21.                 if (window.innerWidth){
  22.                     TypeSize = window.innerHeight
  23.                 } else if (document.all){
  24.                     TypeSize = document.body.clientHeight
  25.                 }
  26.  
  27.                 break;
  28.  
  29.             default:
  30.  
  31.                 break;
  32.  
  33.         }
  34.  
  35.         return TypeSize;
  36.  
  37.     }
  38.  
  39. </script>
 


How would I use this for a table for width and height and would this code work?

Re: Window height/width code - Posted By dog199200 (dog199200) on 7th Jan 10 at 8:07pm
not sure about the code but wouldn't it just be easier using percentage in the height and width area instead of using a JS code {Unsure}

Re: Window height/width code - Posted By Aiken (ionfortuna) on 7th Jan 10 at 8:24pm
The code uses the height and width of the client's window

Re: Window height/width code - Posted By dog199200 (dog199200) on 7th Jan 10 at 8:35pm
ok and if i recall width and height with percentage checks the users res.

Re: Window height/width code - Posted By Aiken (ionfortuna) on 7th Jan 10 at 10:11pm
It doesn't really work out that way

Re: Window height/width code - Posted By Michael (wrighty) on 8th Jan 10 at 12:37am
document.write(Size(x));
or
document.write(Size(y));

{Smile}

Re: Window height/width code - Posted By Aiken (ionfortuna) on 8th Jan 10 at 1:38am
Thanks