码迷,mamicode.com
首页 > Web开发 > 详细

常用JS代码整理

时间:2016-01-12 13:36:01      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

  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: }  

 

常用JS代码整理

标签:

原文地址:http://www.cnblogs.com/twzy/p/5123976.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!