常用JS代码整理
1: function request(paras) {
2: var url = location.href;3: var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");4: var paraObj = {};
5: for (i = 0; j = paraString[i]; i++) {
6: paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);7: }8: var returnValue = paraObj[paras.toLowerCase()];
9: if (typeof (returnValue) == "undefined") {10: return "";
11: } else {
12: return returnValue;
13: }14: }
1: //JS 列出两个日期之间的所有天
2: function show(value1, value2) {
3: var getDate = function (str) {4: var tempDate = new Date();5: var list = str.split("-");6: tempDate.setFullYear(list[0]);7: tempDate.setMonth(list[1] - 1);8: tempDate.setDate(list[2]);9: return tempDate;
10: }11: var date1 = getDate(value1);
12: var date2 = getDate(value2);
13: if (date1 > date2) {
14: var tempDate = date1;
15: date1 = date2;16: date2 = tempDate;17: } date1.setDate(date1.getDate() + 1);18: while (!(date1.getFullYear() == date2.getFullYear() && date1.getMonth() == date2.getMonth() && date1.getDate() == date2.getDate())) {
19: document.write("<div style='display:block'>" + date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate() + "</div>");20: date1.setDate(date1.getDate() + 1);21: }22: }