I have this code to redirect users to the mobile UI. First it will check if it's a mobile second it will check if there is a cookie, and third is to check the URL if NOT contains these words ("DispForm,NewForm,EditForm"). But just doesn't
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
if (document.cookie.indexOf("DesktopView=") < 0) {
if (document.location.href.indexOf('NewForm') === -1 || document.location.href.indexOf('DispForm') === -1 || document.location.href.indexOf('EditForm') === -1) {
document.location = "/_layouts/Mobile/index.aspx";
}
}
}
Can someone tell me why please?