使用wurfl手动返回移动设备上的正常网站



我无法进入它。请给我一个提示。 有一个网站使用wurfl进行设备检测 - javascript方法。 条件如下所示:

if(!WURFL.is_mobile){
$('body').addClass('mobile'); //Do the stuff for mobile website
} else {
$('body').addClass('no-mobile'); // Do the stuff for no-mobile normal website
};

现在我们想在移动版本上放一个按钮,手动切换回正常(非移动(网站。但是网站需要重新加载而不关心原始的wurfl条件,因为在正常(非移动(版本上有一些图像和html插入了javascrit。我不知道该怎么做。

当按下按钮手动转到移动设备或桌面时,您可以像这样设置 cookie:

document.cookie = "forceMobile=true";

然后只需像这样阅读 if 语句中的 cookie:

function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
if(!WURFL.is_mobile && !getCookie("forceMobile")) ...

更多信息在这里