我正在尝试使用Countdown.js。我发现了this guide并复制了代码并将其粘贴以尝试调整和理解代码,但是当我在my web中运行时,我无法使其工作,在控制台中我得到“Uncaught ReferenceError:未定义倒计时(匿名函数)@ countdown..html:46 “。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="countdown.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="stylesheet" href="http://monopolo11.ninja/tests/css/main.css">
<link rel="stylesheet" type="text/css" href="flip/flipclock.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled Document</title>
</head>
<body>
<div id="countdown-holder"></div>
<script>
var clock = document.getElementById("countdown-holder")
, targetDate = new Date(2050, 00, 01); // Jan 1, 2050;
clock.innerHTML = countdown(targetDate).toString();
setInterval(function(){
clock.innerHTML = countdown(targetDate).toString();
}, 1000);
</script>
<br/>
<br/>
You will be logged out in <span id="logout-timer"></span>
<script>
var timer = document.getElementById("logout-timer")
, now = new Date()
, deadline = new Date(now.getFullYear, now.getMonth, now.getDate, now.getHours, now.getMinutes + 15);
timer.innerHTML = countdown(deadline).toString();
setInterval(function(){
timer.innerHTML = countdown(deadline ).toString();
}, 1000);
</script>
</body>
</html>
答案 0 :(得分:1)
指南中使用 c 次数的样本实际应该是 C 次数。
// Declare the countdown object
// Constructor. target_date and current_date are Javascript Date objects
function Countdown(target_date, current_date) {
this.target_date = target_date;
this.current_date = current_date;
}