export
function
getbrowser()
;}
export
function
geturlkey
(name)
(1)寫入帶有自定義有效期的cookie// 使用方式
//這是有設定過期時間的使用示例:
//s20是代表20秒
//h是指小時,如12小時則是:h12
//d是天數,30天則:d30
//用法示例 setcookie("name","hayden","s20"); cookie過期後會自動消失
export
function
setcookie
(name, value, time)
//寫入帶有自定義有效期的cookie的輔助函式
export
function
getsec
(str)
else
if(str2 ==
"h")
else
if(str2 ==
"d")
}
(2)讀取cookiesexport
function
getcookie
(name)
(3)刪除cookiesexport
function
delcookie
(name)
export
function
cloneobj
(obj)
if(obj&&
typeof obj ===
"object")}
}return newobj
};
export
function
gettopost
(data)};
var commonparam = data
var item =
''var key =
''var val =
''let commonparamarr = commonparam.
split
('&');
console.
log(commonparamarr)
; console.
log(
)for
(var i =
0, len = commonparamarr.length; i < len; i++
) console.
log(postdata.values)
;}
export
function
addwatermarker
(str, nodes)
export
function
dataurltoblob
(dataurl)
return
newblob
([u8arr],)
;}
export
function
blobtofile
(theblob, filename)
export
function
curenttime
(dates)
else
var year = now.
getfullyear()
;var month = now.
getmonth()
+1;var day = now.
getdate()
;var today = now.
getday()
;var hh = now.
gethours()
;var mm = now.
getminutes()
;var ss = now.
getseconds()
;var clock = year +
"-";
if(month <
10) clock +=
"0";
clock += month +
"-";
if(day <
10) clock +=
"0";
clock += day +
" ";
if(hh <
10) clock +=
"0";
clock += hh +
":";
if(mm <
10) clock +=
'0';
clock += mm;
return clock
}
export
function
computedages
(str)
)(-|\/)(\d)\2(\d)$/);
if(r==
null
)return
false
;var d=
newdate
(r[1
],r[3]
-1,r[4])
;if(d.getfullyear()
==r[1]
&&(d.
getmonth()
+1)==r[3]
&&d.
getdate()
==r[4]
)return
("輸入的日期格式錯誤!");
}
function
stringtrim
(str)
js封裝常用方法
1 陣列按createtime排序 function sortbycreatetime list any 2 陣列去重 es5function uniq arr es6function uniq arr 3 物件陣列取交集 取物件陣列交集 param list1 陣列 param list2 陣列 ...
常用js驗證方法封裝1
var check 是否為郵件 isemail function str 是否為手機號 isphone function str s trim str if a.test s return true 是否漢字 iscn function str 是否密碼 ispwd function str isw...
js方法的封裝
為什麼要進行方法的封裝?在平時的生產環境中,我們經常寫出這樣的 function fadd ia,ib function fmul ia,ib 其本質上是這樣的 var fadd function ia,ib var fmul function ia,ib 這樣的話,我們就建立了兩個全域性變數,ia...