I have this simple script:
function orientation() {
var orientation = window.orientation;
switch(orientation) {
case 0:
alert('0');
break;
case 90:
alert('90');
break;
case -90:
alert('-90');
break;
}
}
$(document).ready(function(){
window.onorientationchange = orientation();
})
but somehow I never get an alert on my ipad when I turn it... Have I made a mistake somewhere? Thanks for your help guys :).
Here:
window.onorientationchange = orientation;
You need to assign the function itself not the result of its execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With