2011-08-09 21 views
0

このコードはjsFiddleにあります。 http://jsfiddle.net/crashdesk/GbUZ9/Jquery UI Datepicker IE IndexOfエラー

は、それがエラーをスローIE7に問題があるように表示されます。

オブジェクトは私の人生のためにプロパティまたはメソッド「のindexOf」

をサポートしていない私は修正するように見えることはできませんそれ。

そこにいくつかのjavascriptの達人が私を助けてくれますか?

多くのおかげで、 Cここで

答えて

-1
+0

ありがとうございます。それについて読んで、jsFiddleコードと統合しようとしましたが、まだエラーをスローします。 :-( –

+0

IEがうんざりです!これを試してください:http://stackoverflow.com/questions/2608575/jquery-split-and-indexof-results-in-object-doesnt-support-this-property-or-me – Calum

0

は、それがややハックの方法でソートしました。私はIE7の文字列と他のすべてのブラウザ用の配列を作成しなければなりませんでした。

ここからの中古情報...のhttp://minimalbugs.com/questions/share-solve-javascript-error-on-ie-related-to-indexof-function

がうまくいけば、これはいくつかのものであろう誰かに助けてください。ピー!

var months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; 
      var months2 = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"; 

       // initialise the "Select date" link 
       $('#date-pick') 
        .datePicker(
         // associate the link with a date picker 
         { 
          createButton:false, 
          endDate:'31/12/2012' 
         } 
        ).bind(
         // when the link is clicked display the date picker 
         'click', 
         function() 
         { 
          updateSelects($(this).dpGetSelected()[0]); 
          $(this).dpDisplay(); 
          return false; 
         } 
        ).bind(
         // when a date is selected update the SELECTs 
         'dateSelected', 
         function(e, selectedDate, $td, state) 
         { 
          updateSelects(selectedDate); 
         } 
        ).bind(
         'dpClosed', 
         function(e, selected) 
         { 
          updateSelects(selected[0]); 
         } 
        ); 

       var updateSelects = function (selectedDate) 
       { 
        var selectedDate = new Date(selectedDate); 
        $('#d option[value=' + selectedDate.getDate() + ']').attr('selected', 'selected'); 
        $('#m option[value=' + (months[selectedDate.getMonth()]) + '-' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected'); 
       } 
       // listen for when the selects are changed and update the picker 
       $('#d, #m') 
        .bind(
         'change', 
         function() 
         { 
          var d = new Date(
             $('#m').val().split("-")[1], 
             months2.indexOf($('#m').val().split("-")[0]), 
             $('#d').val() 
            ); 
          $('#date-pick').dpSetSelected(d.asString()); 

         } 
        ); 

       // default the position of the selects to today 
       var today = new Date(); 
       updateSelects(today.getTime()); 

       // and update the datePicker to reflect it... 
       $('#d').trigger('change'); 
     }