[英]Check and redirect mobile or desktop traffic
我正在一个html页面上检查流量是移动的还是桌面的。 此后,如果是移动设备,它将重定向到“页面A”,否则,如果是台式机,它将重定向到“页面B”。
现在,我有了这段代码,但无法在移动设备上工作,重定向仅适用于桌面流量。
我该如何解决?
<html>
<head>
<script>if (typeof window.orientation == 'undefined' || len(navigator.plugins.length) > 0){
document.location.href='http://pageA';
}
else {
document.location.href='http://pageB';
}</script>
<title>My test</title>
</head>
<body>
</body>
</html>
我已经将此实现与.htaccess和/或javascript一起使用
您需要对其进行一些修改才能获得所需的结果,但是两种解决方案都提供了一种可靠的检测和重定向方法-
http://www.inmotionhosting.com/support/website/redirects/mobile-redirect
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.