2010-07-22 36 views
1

我必須找錯了,但我找不到竅門:的JavaScript/ASP - 不工作

 <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
<script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script> 
     <script src="http://www.listinventory.com/js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script> 
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 
     <script type="text/javascript" src="http://code.google.com/p/jquery-utils/source/browse/trunk/src/jquery.countdown.js"></script> 
<script type="text/javascript"> 
     $(function hello() { 
      // function that does something exciting? 
      var liftOff = function() { 
       // .... 
      }; 

      // Get a date that is some (short) time in the future 
      var getDeadline = function() { 
       var shortly = new Date(); 
       shortly.setSeconds(shortly.getSeconds() + 5.5); 
       return shortly; 
      }; 

      // Attach click handler to all our buttons 
      $("div.mainpanel button.resetButton").click(function (event) { 

       // I am assuming that you will not be nesting these controls? 
       var $mainpanel = $(this).parents("div.mainpanel") // this will find the mainpanel div that contains the pressed button 
       .effect("highlight", {}, 700); 

       $("div.shortly", $mainpanel) // this will find any div with the class = shortly inside mainpanel 
       .countdown('change', { until: getDeadline() }); 
      }); 

      // Start all countdowns going on page load 
      $('#shortly').countdown({ 
       until: getDeadline(), 
       onExpiry: liftOff, 
       layout: '{sn}' 
      }); 
     }); 

</script> 


    <div class="mainpanel"> 
    <div> 
     test 
    </div> 
    <div class="shortly"> 

    </div> 
    <button class="resetButton"> 
     Reset 
    </button> 
</div> 

</asp:Content> 

我得到一個「Microsoft JScript運行時錯誤:對象不支持此屬性或方法「倒計時的例外。

+0

控制檯上是否有任何錯誤? – jigfox 2010-07-22 12:20:28

+1

顯示倒計時代碼請 – 2010-07-22 12:31:09

+0

如果錯誤處於倒數計時,我們需要相應的代碼,甚至更好,我們需要輸出異常的行號! – jigfox 2010-07-22 12:44:45

回答

0

您可以嘗試從$(function hello() {刪除「hello」 這不是必需的。

倒計時方法的代碼在哪裏?這是在一個JQuery插件或者它是你自己的功能?

+0

好吧,但我得到一個「Microsoft JScript運行時錯誤:對象不支持此屬性或方法」異常。雖然我相信我得到了所有的jQuery腳本。 – Julian 2010-07-22 12:08:42

+0

定義倒計時方法在哪裏? – 2010-07-22 12:09:18

+0

等待我將添加庫網址,該方法應該在jquery.countdown.js – Julian 2010-07-22 12:11:11

0

$mainpanel是否有可能與其他內容相沖突?嘗試將其重命名爲其他名稱(不含$)。

0

我認爲它必須是你如何引用你的插件代碼。我粘貼在線代碼,它沒有和錯誤的工作。

請參閱我的測試:http://jsfiddle.net/3UwCg/