0

I have a bit of JavaScript (jQuery) to catch orientationchange and create a JS alert when triggered:

$('document').ready(function(){

    $('body').bind('orientationchange', function(e){
        alert('orientation change triggered');
    });

});

link: http://jsbin.com/owebax/4

That works fine on an iPhone. It doesn't work on a BlackBerry 9800 running OS6.

In doing some googling, it appears that the issue might be that BlackBerry watches 'window' rather than 'body' for orientation change. I bound the event to window instead: http://jsbin.com/owebax/5

But that still doesn't work on the Blackberry (and now no longer will work on the iPhone.)

Has anyone got orientationchange JS events to fire on the BlackBerry 9800?

Charles
  • 50,943
  • 13
  • 104
  • 142
DA.
  • 39,848
  • 49
  • 150
  • 213
  • 1
    does this help: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Detect-screen-orientation-changes-using-JavaScript/ta-p/445755 – icchanobot Oct 04 '11 at 03:00
  • Yes, it does! In a roundabout way it got me to play with the code some more before finally slapping my forehead in embarrassment. My answer below. ;) – DA. Oct 04 '11 at 04:58

1 Answers1

0

I wish that in addition to 'your answer' for answering your question there was a 'embarrassing user error' flag of some sorts.

So it turns out my issue was simple syntax snafu. Instead of trying to bind to window properly as such:

$(window).bind...

I was looking for a tag called 'window'

$('window').bind...

'doh!

DA.
  • 39,848
  • 49
  • 150
  • 213