Has anyone noticed this behavior? I'm trying to write a script that will trigger upon a resize. It works fine on normal browsers, works fine on iPhone, but on iPad, will only trigger going from horizontal to vertical viewport, not vice versa.
Here's the code:
$(window).resize( function() {
var agent=navigator.userAgent.toLowerCase();
var is_iphone = ((agent.indexOf('iphone') != -1));
var is_ipad = ((agent.indexOf('ipad') != -1));
if(is_iphone || is_ipad){
location.reload(true);
} else {
/* Do stuff. */
};
});
handle the iOS specific event orientationchange by catching window.onorientationchange
I think what you want would be to use the iPad Orientation CSS, which looks like this:
Also, the
orientationchange
event fires when the orientation is changed, according to iPad web development tips.Together, that should give you tools enough to deal with the change.
This includes all orientations.
Here are two options:
or
You want this fix for the orientation bug on iphone and ipad. read about it here: http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
github newest version here: https://gist.github.com/901295 use the second version on the page.
Check your version of iOS.
The "orientationchange" event does not work in iOS 3.*, but it does in 4.*
The only thing I could find from apple:
I understand the "works on the iPhone" part...but maybe it doesn't anymore? This could be a change in OS/mobile Safari since the latest public iPhone OS release shipped (the above documentation is from March 2010).
I'm going to re-tag this question adding iPhone to it, maybe one of the guys with the developer 4.0 OS release can test this? If it is the case it's been removed, this should be a bug filed/fixed before it goes live...I'm not sure on how the procedures are on this with Apple are though.