文刀日月 发表于 2012-12-22 21:32:33

一个sohoto广告弹出页提取时间的Js修改过程

<div id="cnblogs_post_body">以前页面就有浏览器兼容问题 只能ie浏览 今天有空看了一下代码 确实比较糟糕 代码如下:
<div class="cnblogs_code"> 1 <input type="hidden" name="checkInDate" id="checkInDate" /> 2 <SCRIPT LANGUAGE="JavaScript"> 3   var nowtoday = new Date(); 4   var showMonth = nowtoday.getMonth() + 1; 5   var showDate = ""; 6   if (nowtoday.getMonth() < 9) 7     showMonth = "0" + showMonth; 8   if (nowtoday.getDate() < 10) 9     showDate = "0" + nowtoday.getDate();10   else11     showDate = nowtoday.getDate();12 document.getElementById("checkInDate").value = nowtoday.getYear() + "-"13       + showMonth + "-" + showDate;14 </SCRIPT>15 16 <input type="hidden" name="checkOutDate" id="checkOutDate" />17 <SCRIPT LANGUAGE="JavaScript">18   var nowtoday = new Date();19   var nextday = new Date(nowtoday.getTime() + 24 * 3600 * 1000);20   var showMonth = nextday.getMonth() + 1;21   var showDate = "";22   if (nextday.getMonth() < 9)23     showMonth = "0" + showMonth;24   if (nextday.getDate() < 10)25     showDate = "0" + nextday.getDate();26   else27     showDate = nextday.getDate();28 document.getElementById("checkOutDate").value = nextday.getYear() + "-"29       + showMonth + "-" + showDate;30 </SCRIPT>31 32 <script type="text/javascript">33 function goHotelInformation(hotelId){34   var checkInDate=document.getElementById("checkInDate").value;35   var checkOutDate=document.getElementById("checkOutDate").value;36   var path=location.pathname;37   var idx=path.indexOf("/",1);38   var ctx=path.substring(0,idx);39     window.open(ctx+"/htl/order/HotelInfomation.do?hotelId="+hotelId+"&checkInDate="+checkInDate+"&checkOutDate="+checkOutDate+"&c=1&m=1&L=0");40 }41 </script>
页: [1]
查看完整版本: 一个sohoto广告弹出页提取时间的Js修改过程