Domanda

Ecco il codice completo:

  <%@ 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>

Ho la jquery.countdown.js nel Scriptsmap di Visual Studio. Anche il foglio di stile "jquery.countdown.css" è nel progetto.

Do non ha la minima idea di ciò che il problema potrebbe essere. Sono un po 'nuovo per jQuery e cercando di imparare.

È stato utile?

Soluzione

Non ho familiarità con questo plugin conto alla rovescia, ma, provare a spostare la parte

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

nel passato all'oggetto $(document).ready, sostituendo $('#shortly').countdown('change', { until: shortly });

Perché altrimenti il ??shortly var non è inizializzato quando si sta cercando di usarlo.

Altri suggerimenti

si dispone di un errore nella funzione di decollo con windowwindow.location

function liftOff() {
    // refresh the page  
    window.location = window.location;
} 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top