How can I detect window size with jQuery?

后端 未结 6 1926
谎友^
谎友^ 2020-12-08 04:17

How can I detect window/browser size with jQuery like Gmail? In Gmail, we don\'t need to refresh or reload current page as soon as we have changed window resolution in windo

6条回答
  •  囚心锁ツ
    2020-12-08 04:23

    //get dimensions 
    var height = $(window).height();
    var width = $(window).width();
    
    //refresh on resize
    $(window).resize(function() {
      location.reload(true)
    });
    

    not sure if you wanted to tinker with the dimensions of elements or actually refresh the page. so here a bunch of different things pick what you want. you can even put the height and width in the resize event if you really wanted.

提交回复
热议问题