Detect screen orientation

Hello everyone.
@slackmoehrle @pandamicro
I have a game that runs in landscape mode. But if the game is opened in portrait mode its shows “Rotate your device” message. And that message should disappear when the device is rotated. I have added the below code

window.addEventListener("orientationchange", function() {
     if(screen.orientation.angle == 90){
           this.orientationNode.active = false;
     }
}.bind(this));

but this requires enabling auto rotate setting in the device. Is there any other way to check if the device is rotated or not. The game run in browser.
thank you

Hello there,

I think Cocos Creator already takes care of that.
No matter what the device’s orientation is, the game will stick to the option we choose when the game is built (ie: portrait or landscape).

Try to build the game for web-mobile and hope it works for you.

Yes that works fine. The game will stick to the landscape. But if the device orientation is portrait then rotate device message is displayed and once the device is rotated it should disappear.
Thank you

which Cocos Creator version are you using?
I’ve tested with the followings:
For 2.1, the game is auto rotated regardless of screen orientation.
For 3.3, the game stick to the option we used during build.

version is 2.4.3
Here also the game stick to the landscape. But what I want is if the device orientation is portrait(the game will be in landscape only), rotate your device should appear.