当前位置:网站首页>Jump to the mobile terminal page or PC terminal page according to the device information

Jump to the mobile terminal page or PC terminal page according to the device information

2022-07-07 10:23:00 weixin_ forty-two million one hundred and seventy-eight thousan

The code is as follows :

function browserRedict(pcurl, moburl) {
    
	let userAgentInfo = navigator.userAgent.toLowerCase();
	let device = /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/;
	if(device.test(userAgentInfo)){
    
		window.location.href = moburl;
	} else {
    
		window.location.href = pcurl;
	}
};

browserRedict("pc.example.com", "mob.example.com");
原网站

版权声明
本文为[weixin_ forty-two million one hundred and seventy-eight thousan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070810386980.html