javascript - iPad doesn't trigger resize event going from vertical to horizontal? -
has noticed behavior? i'm trying write script trigger upon resize. works fine on normal browsers, works fine on iphone, on ipad, trigger going horizontal vertical viewport, not vice versa.
here's 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 { /* stuff. */ }; });
if understood correctly, want when user tilts ipad. here go:
window.onorientationchange = function(){ var orientation = window.orientation; // @ value of window.orientation: if (orientation === 0){ // ipad in portrait mode. } else if (orientation === 90){ // ipad in landscape mode. screen turned left. } else if (orientation === -90){ // ipad in landscape mode. screen turned right. } }
Comments
Post a Comment