我正在尝试重定向桌面设备更改脚本:
if (screen.width <= 699) {
document.location = "Other URL";
}699到主要宽度,但不能工作。请问如何才能做到重定向?我的目的是只为桌面,但我有成功,只有移动。艾比建议?
发布于 2022-03-19 20:16:02
下面是在现代浏览器版本上使用ECMA6 works的脚本。也可以为桌面设备裁剪页面。
var isMobile = navigator.userAgent.toLowerCase().indexOf('mobile') > -1;
var getChromeVersion = function() {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
};
console.log('isMobile :' + isMobile)
console.log('getChromeVersion :' + getChromeVersion())
if (isMobile == false) {
// if device is desktop then redirect our page
window.location.replace("https://maximumroulette.com");
// OR
// window.location.href = "https://www.google.com";
}
https://stackoverflow.com/questions/71541531
复制相似问题