【问题标题】:Check and redirect mobile or desktop traffic检查和重定向移动或桌面流量
【发布时间】:2016-04-29 18:18:10
【问题描述】:

我正在开发一个 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>

【问题讨论】:

标签: javascript html redirect mobile desktop


【解决方案1】:

我已将此实现与 .htaccess 和/或 javascript 一起使用

需要对您想要的结果进行一些修改,但两种解决方案都提供了一种可靠的检测和重定向方法 -

http://www.inmotionhosting.com/support/website/redirects/mobile-redirect

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多