function getDateFromUrl(url)
{
var urlDateString = url.substring(url.lastIndexOf('/day/')+5);
urlDateString =urlDateString.replace("/index-1.html","");
urlDateString =urlDateString.replace("th","");
urlDateString =urlDateString.replace("rd","");
urlDateString =urlDateString.replace("st","");
urlDateString =urlDateString.replace(","," ");
urlDateString =urlDateString.replace("/"," ");
urlDateString =urlDateString.replace("-"," ");
urlDateString =urlDateString.replace("."," ");
urlDateString =urlDateString.replace(","," ");
urlDateString =urlDateString.replace("/"," ");
urlDateString =urlDateString.replace("-"," ");
urlDateString =urlDateString.replace("."," ");
return new Date(urlDateString);
}
function getDayFromDate(dt)
{
switch (dt.getDay())
{
case 0:
x="Sunday";
break;
case 1:
x="Monday";
break;
case 2:
x="Tuesday";
break;
case 3:
x="Wednesday";
break;
case 4:
x="Thursday";
break;
case 5:
x="Friday";
break;
case 6:
x="Saturday";
break;
}
return x;
}
IE 和opera 不支持这个脚本。因为它们不输出日期,而 chrome 和 firefox 确实输出日期。会不会是因为他们不支持字符串格式的日期。如果是这样,日期必须采用哪种格式。
输入看起来像 C:\example\day\12-October-12 输出应该是 date: Oct 12 2012 day: Friday 代码的方式是 atm 它在 chrome 和 firefox 中工作
任何帮助表示赞赏。