我遇到了同样的问题,感谢上帝,我刚刚在这里找到了一个解决方案:
您必须在 Jquery.countdown.js 中的选项签名中添加一个新参数:
this._defaults = {
until: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
// or numeric for seconds offset, or string for unit offset(s):
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
// or numeric for seconds offset, or string for unit offset(s):
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
timezone: null, // The timezone (hours or minutes from GMT) for the target times,
// or null for client local
serverSync: null, // A function to retrieve the current server time for synchronisation
format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
layout: '', // Build your own layout for the countdown
compact: false, // True to display in a compact format, false for an expanded one
significant: 0, // The number of periods with values to show, zero for all
description: '', // The description displayed for the countdown
expiryUrl: '', // A URL to load upon expiry, replacing the current page
expiryText: '', // Text to display upon expiry, replacing the countdown
alwaysExpire: true, // True to trigger onExpiry even if never counted down
onExpiry: null, // Callback when the countdown expires -
// receives no parameters and 'this' is the containing division
onTick: null, // Callback when the countdown is updated -
// receives int[7] being the breakdown by period (based on format)
// and 'this' is the containing division
tickInterval: 1 ,// Interval (seconds) between onTick callbacks
identifier:''
};
那么你应该在函数调用中添加你的标识符
if (onExpiry) {
onExpiry.apply(target,[this._get(inst, 'identifier')]);
}
那么对 UpdateCountdown 的调用将如下所示
$('#defaultCountdown).countdown({identifier:1,onExpiry: yourFuncion, until: new Date('2012-01-04')});
您的函数将如下所示:
function yourFunction(id){
alert(id);
}
您可以将 Jquery.countdown.js 上的 alwaysExpire 设置为 true ,这样您就可以测试提前过期的日期。