使用JavaScript实现网页跳转到in.html
以下代码使用JavaScript检测用户设备类型,并根据结果将用户跳转至相应的页面。
var isQQ = navigator.userAgent.indexOf('QQ/') !== -1;
var isWechat = navigator.userAgent.indexOf('MicroMessenger') !== -1;
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (isQQ || isWechat) {
alert('请使用浏览器打开');
} else if (isMobile) {
window.location.href = 'https://m.example.com';
} else {
window.location.href = 'https://www.example.com';
}
如果要直接跳转到in.html,可以使用以下代码:
window.location.href = 'in.html';
请根据实际情况修改代码中的目标页面地址。
原文地址: https://www.cveoy.top/t/topic/jqkr 著作权归作者所有。请勿转载和采集!