5

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 :).

cmplieger
  • 7,155
  • 15
  • 55
  • 83

1 Answers1

5

Here:

window.onorientationchange = orientation;

You need to assign the function itself not the result of its execution.

bjornd
  • 22,397
  • 4
  • 57
  • 73