hi,
I’m having a problem with jQ Mobile’s orientationchange event…
how exactly do you test for what orientation the window is in?
I used to think it was
if (window.orientation == 0) { // (for portrait)
but it’s not giving me expected result (and at any rate
window.orientation prints ‘undefined’ in console.log() stmt…(???)
so checked out documentation, and am also trying
if (event.orientation === 'portrait') {.....}
but problem persists… what I need is to get the window height every time I change orientation (of course this changes when you change orientation, but this does not seem to register w/this orientationchange event…)
and other simple CSS changes on or-chg event, but nothing works, unless I reload the page after or-change…
code to illustrate problem:
winHeight = $(window).height();
console.log(winHeight);
$(window).on('orientationchange',function(event) {
if (window.orientation == 0) {
console.log(event.orientation); // prints as expected - 'portrait'
console.log(window.orientation); // prints 'undefined' (????)
console.log(winHeight); // does not get adjusted on orient.-chg
$('.photoImg').css('border','solid 1px green'); // takes only if reload pg
} else { // if (window.orientation == 90)
console.log(event.orientation); // prints as expected - 'landscape'
console.log(winHeight);// does not get adjusted on or-chg, i.e,
// if load portrait then switch to landscape this prints the same win height as for portrait (????)
$('.photoImg').css('border','solid 1px green'); // takes only if reload pg
}
})
;
if I test orientation with event.orientation instead of window.orientation have same problem…
and the example from here
$(window).bind('orientationchange',function(){
if(event.orientation == 'portrait'){
alert('portrait');
}
else if(event.orientation == 'landscape') {
alert('landscape');
}
});
also isn’t working… (do not see any alerts at all when chg orientation…)
have been struggling with this for days… would appreciate some help…
thank you…