Closed
Bug 964565
Opened 12 years ago
Closed 11 years ago
www.leparisien.fr sends desktop site to Firefox OS
Categories
(Web Compatibility :: Site Reports, defect)
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: karlcow, Assigned: karlcow)
References
()
Details
(Whiteboard: [clientsniff] [country-fr] [sitewait])
Attachments
(1 file)
|
335.90 KB,
image/png
|
Details |
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;
}
}
}
| Assignee | ||
Comment 1•11 years ago
|
||
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]
| Assignee | ||
Comment 2•11 years ago
|
||
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.
| Assignee | ||
Comment 3•11 years ago
|
||
This is fixed!
http://twitter.com/SachaMorard/status/482498572483833856
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
Status: RESOLVED → VERIFIED
Updated•7 years ago
|
Product: Tech Evangelism → Web Compatibility
Updated•2 years ago
|
Component: Mobile → Site Reports
You need to log in
before you can comment on or make changes to this bug.
Description
•