codergautamyt

getViewportDimensions.js

Oct 8th, 2021
880
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function viewport()
  2. {
  3. var e = window
  4. , a = 'inner';
  5. if ( !( 'innerWidth' in window ) )
  6. {
  7. a = 'client';
  8. e = document.documentElement || document.body;
  9. }
  10. return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }
  11. }
  12.  
  13. /*
  14. USAGE:
  15.  
  16. var width = viewport().width
  17. var height = viewport().height
  18. */
RAW Paste Data