views:

330

answers:

2

Here is the full code:

  <%@ 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"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"&gt;&lt;/script&gt;
    <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>

I've got the jquery.countdown.js in the Scriptsmap of visual studio. Also the stylesheet "jquery.countdown.css" is in the project.

Don't have a clue about what the problem could be. I'm kind of new to jquery and trying to learn it.

A: 

you have a error in liftOff function with windowwindow.location

function liftOff() {
    // refresh the page  
    window.location = window.location;
} 
Elph
Ah didnt notice that, thanks. But still my timer isn't showing.
Julian
A: 

I'm not familiar with this countdown plugin, but, try moving the part

    $('#shortly').countdown({ until: shortly,
        onExpiry: liftOff, layout: "{ps} seconds to go"
    });

into the function passed to $(document).ready, replacing $('#shortly').countdown('change', { until: shortly });

Because otherwise the shortly var is not initialized when you're trying to use it.

Jan Willem B
Thanks alot Jan Willem!
Julian
you're welcome.
Jan Willem B