Detecting orientation change on BlackBerry 9800 via JavaScript

460 Views Asked by At

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?

1

There are 1 best solutions below

0
On

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!