How to get the correct window width on orientation

2020-07-14 09:54发布

I am trying to calculate the window width on orientation change for android devices using jquery function $(window).outerWidth(true);. This calculation gives correct width on orientation change for both iphone and ipad but not in android. If i initially load the page in landscape mode or portrait mode i am getting the correct width but once i change the orientation after loading the page i am getting the width for portrait mode as was in landscape mode and vice versa. Please suggest what is happening and how can i handle this issue so that i get the correct window width on orientation change in android device

7条回答
三岁会撩人
2楼-- · 2020-07-14 10:22

Try window.innerWidth, respectively, window.innerHeight; It is posible that android doesn't not about outerWidth and Height;

查看更多
登录 后发表回答