var strURL = "Data_SalesByCategory.aspx?Year=" + year;
strURL = strURL + "&currTime=" + getTimeForURL();
/**
* getTimeForURL method returns the current time
* in a URL friendly format, so that it can be appended to
* dataURL for effective non-caching.
*/
function getTimeForURL(){
var dt = new Date();
var strOutput = "";
strOutput = dt.getHours() + "_" + dt.getMinutes() + "_" + dt.getSeconds() + "_" + dt.getMilliseconds();
return strOutput;
}
本文介绍了一种通过在URL中附加当前时间戳来避免浏览器缓存数据的方法。具体实现是定义了一个JavaScript函数`getTimeForURL()`,该函数返回当前时间的一种特定格式,包括小时、分钟、秒和毫秒,然后将此时间戳追加到指定的URL后面。

2171

被折叠的 条评论
为什么被折叠?



