asp.net/jquery-カウントダウンタイマーが機能していません
質問
これが完全なコードです:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<style type="text/css">
@import "jquery.countdown.css";
</style>
<script type="text/javascript" src="Scripts/jquery.countdown.js"></script>
<script type="text/javascript">
$('#shortly').countdown({ until: shortly,
onExpiry: liftOff, layout: "{ps} seconds to go"
});
$(document).ready(function () {
shortly = new Date();
shortly.setSeconds(shortly.getSeconds() + 5.5);
$('#shortly').countdown('change', { until: shortly });
});
function liftOff() {
// refresh the page
window.location = window.location;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<span id="shortly"></span>
</form>
</body>
</html>
Visual Studioのスクリプトマップにjquery.countdown.jsがあります。また、スタイルシート「jquery.countdown.css」がプロジェクトにあります。
問題が何であるかについての手がかりを持っていません。私はjqueryにちょっと慣れていて、それを学ぼうとしています。
解決
私はこのカウントダウンプラグインに精通していませんが、パーツを移動してみてください
$('#shortly').countdown({ until: shortly,
onExpiry: liftOff, layout: "{ps} seconds to go"
});
に渡された関数に $(document).ready
, 、交換 $('#shortly').countdown('change', { until: shortly });
そうでなければ shortly
VARは、使用しようとしているときに初期化されません。
他のヒント
リフトオフ機能にエラーがあります windowwindow.location
function liftOff() {
// refresh the page
window.location = window.location;
}
所属していません StackOverflow