Problem about code to make a map not work in firefox

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Posts: 12
Joined: August 19th, 2015, 1:01 am
Location: tech

Post Posted August 22nd, 2015, 12:37 am

Hello all member!
The following code is supposed to make a map on a web page be the only element that is displayed on the page when the phone is turned sideways, and then re-adds the other elements when the phone is turned back to it's original portrait orientation. This works in Chrome for Android but does not work in FireFox v39 for Android.

The first alert fires in FireFox, so I know that device orientation is supported, but the second alert never fires in FireFox, so there is something wrong with my second conditional.

Code: Select all
if (window.DeviceOrientationEvent) {
        window.addEventListener('deviceorientation', function (eventData) {
            if (window.orientation == 90 || window.orientation == -90) {
                alert("90 or -90");
                $("#mapTop").css("display", "none");
                $("#mapBottom").css("display", "none");
            else {
                $("#mapTop").css("display", "block");
                $("#mapBottom").css("display", "block");

Thank You Very much!
Have a nice day!


User avatar
Posts: 122510
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted August 22nd, 2015, 4:47 am

Moving to Web Development.


User avatar
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium

Post Posted August 22nd, 2015, 12:15 pm

Why not just console.log the eventData?

Anyhoo, MDN has ... rientation
Intelligent alien life does exist, otherwise they would have contacted us.


User avatar
Posts: 10780
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted August 23rd, 2015, 6:00 pm

Does your Firefox recognize window.orientation at all?

You could try window.screen.orientation (actually mozOrientation for now), it seems simpler than reading angles:


User avatar
Posts: 27654
Joined: June 18th, 2003, 3:07 pm
Location: Made in Canada

Post Posted August 30th, 2015, 2:55 pm

This same posting is posted on a number of other sites in last while.

Return to Web Development / Standards Evangelism

Who is online

Users browsing this forum: No registered users and 2 guests