www.leparisien.fr sends desktop site to Firefox OS

VERIFIED FIXED

Status

Tech Evangelism
Mobile
VERIFIED FIXED
5 years ago
3 years ago

People

(Reporter: karlcow, Assigned: karlcow)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [clientsniff] [country-fr] [sitewait], URL)

Attachments

(1 attachment)

Created attachment 8366342 [details]
021.png

The script is detecting a bunch of mobile devices/browsers but not everything.

var navt = "Android,Bada,Symbian,Windows Phone,Blackberry,Blazer,Elaine,Handspring,HTC,IEMobile,iPad,iPhone,iPod,Kyocera,LG,MIDP,Motorola,NetFront,Nokia,Palm,PlayStation Portable,Samsung,Smartphone,SonyEricsson,Symbian,UP.Browser,WAP,Windows CE".split(",");


For example, Firefox OS User Agent is not caught. They could simplify a lot by just looking for /mobi/i




The full script.
=============
var mobile_url = "http://m.leparisien.fr";
var redirectUrl = encodeURIComponent(window.location.href.toString().split(window.location.host)[1]);
var userAgent = navigator.userAgent;
var mobileDevice = false;
var cookieDate = new Date;
cookieDate.setFullYear(cookieDate.getFullYear() + 1);
var navt = "Android,Bada,Symbian,Windows Phone,Blackberry,Blazer,Elaine,Handspring,HTC,IEMobile,iPad,iPhone,iPod,Kyocera,LG,MIDP,Motorola,NetFront,Nokia,Palm,PlayStation Portable,Samsung,Smartphone,SonyEricsson,Symbian,UP.Browser,WAP,Windows CE".split(",");
for (e = 0; e < navt.length; e++) {
    if (userAgent.indexOf(navt[e]) != -1) {
        mobileDevice = true;
    }
}
if (mobileDevice) {
    if (document.cookie.indexOf('LPVERSIONMOB') != -1) {
        if (document.cookie.indexOf('LPVERSIONMOB=1') != -1) {
            if (userAgent.indexOf('iPad') != -1) {
                document.cookie = 'LPVERSIONMOB=1;path=/;expires=' + cookieDate.toGMTString() + ';domain=leparisien.fr';
            }
            window.location.href = mobile_url + "/redirect?url=" + redirectUrl;
        }
    } else {
        if ((userAgent.indexOf('iPad') != -1)) {
            if (confirm("Voulez-vous être redirigé vers le site optimisé pour mobile ?")) {
                document.cookie = 'LPVERSIONMOB=1;path=/;expires=' + cookieDate.toGMTString() + ';domain=leparisien.fr';
                window.location.href = mobile_url + "/redirect?url=" + redirectUrl;
            } else {
                document.cookie = 'LPVERSIONMOB=0;path=/;expires=' + cookieDate.toGMTString() + ';domain=leparisien.fr';
            }
        } else {
            document.cookie = "LPVERSIONMOB=1;path=/;domain=leparisien.fr";
            window.location.href = mobile_url + "/redirect?url=" + redirectUrl;
        }
    }
}
Trying to find the appropriate contact.
http://twitter.com/MozWebCompat/status/480981671848583169
Assignee: nobody → kdubost
Status: NEW → ASSIGNED
Whiteboard: [clientsniff] [country-fr] [contactready] → [clientsniff] [country-fr] [sitewait]
For Le Parisien team. Feel free to ask me more details.

So currently the test is done on the client side.

"Android,Bada,Symbian,Windows Phone,Blackberry,Blazer,Elaine,Handspring,HTC,IEMobile,iPad,iPhone,iPod,Kyocera,LG,MIDP,Motorola,NetFront,Nokia,Palm,PlayStation Portable,Samsung,Smartphone,SonyEricsson,Symbian,UP.Browser,WAP,Windows CE"

To note that many of these already have a "Mobile" token in their user agent string: iPad, iPhone, iPod, IEMobile, etc. So we usually recommend to catch the 'mobi' string.

var mobileDevice = false;
var ua = navigator.userAgent.toLowerCase();
// put inside what you think is good.
var navt      = "android,mobi,…".split(",");
// could use also var navt = ['android', 'mobi', …]
// testing the UA
for (e = 0; e < navt.length; e++) {
    if (ua.indexOf(navt[e]) != -1) {
        mobileDevice = true;
    }
}

The specific User Agent strings of Firefox in general and Firefox OS in particular are at:
https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference#Firefox_OS

Thanks.
This is fixed!
http://twitter.com/SachaMorard/status/482498572483833856
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.