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
相关问题
- Is there a limit to how many levels you can nest i
- How can I create this custom Bottom Navigation on
- How to toggle on Order in ReactJS
- Bottom Navigation View gets Shrink Down
- How to fix IE ClearType + jQuery opacity problem i
Why not just use the javascript
screen
object. you should be able to get the screen dimensions with :Instead of listening to orientationchange event , you can listen to window resize event , it will make sure that window.innerHeight/outerHeight properties got updated.
this post seems to have a solution that may be relevant to you:
http://forum.jquery.com/topic/orientationchange-event-returns-wrong-values-on-android
I was also stuck in this problem and find the best solution which will work on all the platforms.Below is the code of 'orientationchange' event.
Hope, it will help you and most of other too.. Cheers.
This is ugly, but it works. Mobile viewport height after orientation change