My website uses static cache, which causes the wp_is_mobile()function to fail
Is there any js method that can replace the wp_is_mobile() function? In order to
make certain js and css load only on the PC side, but not on the mobile side. (Baidu and Google are broken, if you have a good method, please help)
static cache, which causes the wp_is_mobile()function to failIs there any js method that can replace the wp_is_mobile() function
? In order to make certain js and css load only on the PC side, but not on the mobile side.
(Baidu and Google are broken, if you have a good method, please help)
<code>var browserRedirect = function() { var sUserAgent = navigator.userAgent.toLowerCase(); var systemclass = {}; systemclass.bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; systemclass.bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; systemclass.bIsMidp = sUserAgent.match(/midp/i) == "midp"; systemclass.bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; systemclass.bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; systemclass.bIsAndroid = sUserAgent.match(/android/i) == "android"; systemclass.bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; systemclass.bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; systemclass.bIsWX = sUserAgent.match(/MicroMessenger/i) == "micromessenger"; return systemclass; }; var nowclass = browserRedirect(); if (nowclass.bIsIpad || nowclass.bIsIphoneOs || nowclass.bIsMidp || nowclass.bIsUc7 || nowclass.bIsUc || nowclass.bIsAndroid || nowclass.bIsCE || nowclass.bIsWM) { if (nowclass.bIsIphoneOs || nowclass.bIsIpad || nowclass.bIsMidp) { //如果是ios移动设备 window.location.href = "ios需要跳转的地方"; if (nowclass.bIsWX) { //解决以微信内核浏览器打开无法直接跳转给出提示点击跳转至safari打开 document.getElementById("tipsid").style.display = "block"; } } else if (nowclass.bIsAndroid) { //如果是android移动设备 window.location.href = "android需要跳转的地方"; } } else { window.location.href = "PC端跳转去的地方"; } </code>