How to detect the landscape/portraite mode?
i found the answer from forum Nokia, as following:
window.onresize = handleOrientation;
function handleOrientation()
{
// landscape mode
if (window.screen.width > window.screen.height) {
...
}
else { // portrait mode
...
}
}
but i use totally the same method to detect,
it doesn't work in S60 5th emulator.
This problem stock me for a long time~
Are there any other way to detect the monitor mode?
please help me~:(
Re: How to detect the landscape/portraite mode?
[QUOTE=alexbubble;492562]i found the answer from forum Nokia, as following:
window.onresize = handleOrientation;
function handleOrientation()
{
// landscape mode
if (window.screen.width > window.screen.height) {
...
}
else { // portrait mode
...
}
}
but i use totally the same method to detect,
it doesn't work in S60 5th emulator.
This problem stock me for a long time~
Are there any other way to detect the monitor mode?
please help me~:([/QUOTE]
The code above relies on the fact that the screen width is larger than screen height when in "landscape" mode and vice versa in "portrait" mode. Do you actually get the screen to change from landscape to portrait on the S60 5th edition device emulation? And if so, are you saying that despite the fact that the screen resolution changes you still have the width and height remaining the same as they were? Or are you saying that you don't get a screen resize callback, or what?
Re: How to detect the landscape/portraite mode?
[QUOTE=peppe@peppe.net;493932]The code above relies on the fact that the screen width is larger than screen height when in "landscape" mode and vice versa in "portrait" mode. Do you actually get the screen to change from landscape to portrait on the S60 5th edition device emulation? And if so, are you saying that despite the fact that the screen resolution changes you still have the width and height remaining the same as they were? Or are you saying that you don't get a screen resize callback, or what?[/QUOTE]
thank you for your response, i think i really need to specify my question.
i used this method on S60 3.2 emulator, it did get the screen size, detect the screen mode and successfully did the javascript.
i try to just fetch the screen size on 5th emulator, like
alert(window.screen.width);
but it didn't work. i guess this is why i can't use this method to detect the screen mode.
are there any possible method to detect the screen mode?
:confused:
Re: How to detect the landscape/portraite mode?
Hi,
I'm discussing about this issue in S60 5th Edition with our browser folks.
For the short term solution, the only quick and dirty hack that came to my mind is to poll for the screen size change.
function poll(){
setInterval("triggerInterval()", 2000);
}
function triggerInterval(){
alert(screen.width + 'x' + screen.height);
}
Re: How to detect the landscape/portraite mode?
Try this code, it may helps you.
[CODE]
// check the orientation, on every window.resize event occurs
window.onresize = checkOrientation;
function checkOrientation()
{
// Portrait mode
if(window.innerWidth < window.innerHeight){
alert('Portrait mode: ' + window.innerWidth + 'x' + window.innerHeight);
}
else{
alert('Landscape mode: ' + window.innerWidth + 'x' + window.innerHeight);
}
}
[/CODE]