Closed Bug 959498 Opened 10 years ago Closed 10 years ago

m.caixin.com javascript sniffer shows blank page in Firefox OS

Categories

(Web Compatibility :: Site Reports, defect)

All
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: hsteen, Assigned: yliu)

References

()

Details

(Whiteboard: [clientsniff] [country-cn] [contactready])

The JS sniffing in http://file.caixin.com/webjs/content/redirect.js?20130903 fails to forward the Firefox OS browser anywhere.

var vLink = window.location.href;
if(vLink.indexOf("//mob.")>0){
	window.location.href = vLink.replace("//mob.","//m.");
}
if(vLink.indexOf("NOJP")<0){
	var sUserAgent = navigator.userAgent.toLowerCase();
	var isPad = (sUserAgent.indexOf("ipad;")>0)?true:false;
	var isMob = ((sUserAgent.indexOf("iphone os")>0)?true:false)||((sUserAgent.indexOf("midp")>0)?true:false)||((sUserAgent.indexOf("rv:1.2.3.4")>0)?true:false)||((sUserAgent.indexOf("ucweb")>0)?true:false)||((sUserAgent.indexOf("android")>0)?true:false)||((sUserAgent.indexOf("windows ce")>0)?true:false)||((sUserAgent.indexOf("windows mobile")>0)?true:false)||((sUserAgent.indexOf("iemobile")>0)?true:false)||((sUserAgent.indexOf("wpdesktop")>0)?true:false);
	if(isPad && (vLink.indexOf("//m.")<0 || vLink.indexOf("/ipad/")<0)){
		if(vLink.indexOf("//m.")<0){
			var vTemp = vLink.substr(7);
			var vMain = vTemp.substr(0,vTemp.indexOf("/"));
			if(vMain.indexOf("www.")==0){
				vMain = vMain.substr(4);
			}
			var vTail = vTemp.substr(vTemp.indexOf("/"));
			window.location.href = "http://m."+vMain+"/ipad"+vTail;
		}
		else if(vLink.indexOf("/ipad/")<0 && vLink.indexOf("/m/")>0){
			window.location.href = vLink.replace("/m/","/ipad/");
		}
		else if(vLink.indexOf("/ipad/")<0 && vLink.indexOf("/m/")<0){
			window.location.href = vLink.replace(".com/",".com/ipad/");
		}
	}
	if(isMob && (vLink.indexOf("//m.")<0 || vLink.indexOf("/m/")<0)){
		if(vLink.indexOf("//m.")<0){
			var vTemp = vLink.substr(7);
			var vMain = vTemp.substr(0,vTemp.indexOf("/"));
			if(vMain.indexOf("www.")==0){
				vMain = vMain.substr(4);
			}
			var vTail = vTemp.substr(vTemp.indexOf("/"));
			window.location.href = "http://m."+vMain+"/m"+vTail;
		}
		else if(vLink.indexOf("/m/")<0 && vLink.indexOf("/ipad/")>0){
			window.location.href = vLink.replace("/ipad/","/m/");
		}
		else if(vLink.indexOf("/m/")<0 && vLink.indexOf("/ipad/")<0){
			window.location.href = vLink.replace(".com/",".com/m/");
		}
	}
}
Assignee: nobody → yliu
Status: NEW → ASSIGNED
This is fixed.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → WORKSFORME
Product: Tech Evangelism → Web Compatibility
Component: Mobile → Site Reports
You need to log in before you can comment on or make changes to this bug.