why is $(window).height() so wrong?

前端 未结 6 983
遥遥无期
遥遥无期 2020-12-10 11:21

I\'m trying to get the current browser viewport height, using

$(window).on(\'resize\',function() { 
  console.log(\"new height is: \"+$(window).height()); 
         


        
6条回答
  •  死守一世寂寞
    2020-12-10 11:34

    No repro. Keep in mind that the window height is diminished by items in the browser's chrome, such as the address bar, developer tools, bookmarks toolbars and more. The following appears to show an accurate representation of the viewport height:

    jsbin will give you a pretty good estimation of the window height, as it doesn't limit your code output to a small iframe like other js-testing sites such as jsfiddle.

    http://jsbin.com/otaqej/edit#javascript,html

    
    
      
        
      
      
        
    Height: 0

提交回复
热议问题