js判斷是否是PC,IOS,Android客戶端

2022-02-07 02:53:43 字數 1530 閱讀 4150

在專案中使用html5,需要針對不同的客戶端瀏覽器有不一樣的處理方式,這就需要對請求中的useragent進行分析,並進行處理。

為了自適應頁面可以加上這個meta

<

meta

name

="viewport"

content

="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"

/>

測試

這裡記錄一下,以後會經常用到。

js判斷是否是陣列,變數是否存在

let arr 1 方法一 isprototypeof 函式 用於指示物件是否存在於乙個物件的原型鏈中。console.log array.prototype.isprototypeof arr true 方法二 instanceof 變數 instanceof 型別 console.log arr...

js判斷當前時區 TimeZone 是否是夏令時

var d1 new date 2009,0,1 var d2 new date 2009,6,1 if d1.gettimezoneoffset d2.gettimezoneoffset else 其實 d1 無論是哪一年的 1.1 日都可以,d2 與 d1 是同年的日期,即可判斷。附 getti...

判斷是否是閏年

使用者輸入月份,判斷當前月份為幾月,並輸出有多少天。如果使用者輸入2月份,則請使用者輸入年份,判斷平年則輸出28天,閏年則輸出29天。能被4整除但不能被100整除,或者能被400整除 months input 請輸入當前月份 while notmonths.isdigit or int months...