×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    3

    Smile 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~

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Posts
    60

    Re: How to detect the landscape/portraite mode?

    Quote Originally Posted by alexbubble View Post
    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~
    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?

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    3

    Smile Re: How to detect the landscape/portraite mode?

    Quote Originally Posted by peppe@peppe.net View Post
    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?
    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?

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Posts
    115

    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);
    }

  5. #5
    Nokia Developer Expert
    Join Date
    Oct 2008
    Posts
    9

    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);
    	}
    }

Similar Threads

  1. How to detect offline mode in 2nd Edition
    By Asif Nazir in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-05-09, 07:16
  2. How to detect offline mode in 2nd Edition
    By Asif Nazir in forum Symbian
    Replies: 1
    Last Post: 2008-05-08, 14:31
  3. skinning in landscape mode.
    By ravinder007 in forum Symbian
    Replies: 0
    Last Post: 2007-01-24, 11:01
  4. Skinning in landscape mode.
    By ravinder007 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2007-01-11, 10:24
  5. How to detect standby mode in 3650?
    By Utk in forum Symbian
    Replies: 0
    Last Post: 2004-06-08, 15:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×