Posted By

djstaz0ne on 04/02/10


Tagged

javascript width ie window Opera height ff cross-compatible


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

NeekGerd


Get Window Height and Width (Cross-Compatible)


 / Published in: JavaScript
 

URL: http://perpetualtechnologies.net

Returns window size as object. winsize.x = window width; winsize.y = window height;

  1. function getWindowSize(){
  2. var x = 0;
  3. var y = 0;
  4. if (self.innerHeight)
  5. {
  6. x = self.innerWidth;
  7. y = self.innerHeight;
  8. }
  9. else if (document.documentElement && document.documentElement.clientHeight)
  10. {
  11. x = document.documentElement.clientWidth;
  12. y = document.documentElement.clientHeight;
  13. }
  14. else if (document.body)
  15. {
  16. x = document.body.clientWidth;
  17. y = document.body.clientHeight;
  18. }
  19. return {"x":x,"y":y};
  20. }

Report this snippet  

You need to login to post a comment.