1. 程式人生 > >手機和電腦端分開跳轉

手機和電腦端分開跳轉

 <title>我的第一個 HTML 頁面</title>


<script type="text/javascript">
    var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");


    var browser = navigator.userAgent.toLowerCase();


    var isMobile = false;


    for (var i = 0; i < mobileAgent.length; i++) {


        if (browser.indexOf(mobileAgent[i]) != -1) {
            isMobile = true;
            alert("我要去手機適配的頁面咯~");
            // location.href = 'app.html';   //匹配到就跳轉到適配手機的html


            break;
        }
    }
    alert("我要去web頁面咯~");
    //location.href = web.jsp';  //這裡調到服務端
</script>




    把註釋去掉,配上自己相應的路徑就能跳轉哦