1. 程式人生 > >js 判斷瀏覽器處於pc端或手機端

js 判斷瀏覽器處於pc端或手機端

if (/Android|webOS|iPhone|iPod|BlackBerry/g.test(navigator.userAgent)) {
    window.location.href = "http://phone";
} else {
    window.location.href = "http://computer";
}