Datepicker在IE8中不起作用

时间:2012-09-17 14:21:50

标签: javascript jquery

嗨我有一个问题,我的日期选择器没有使用IE7或8,在Chrome和Firefox中工作得很好,任何人都可以对这个问题有所了解,我是一个相对新手,所以任何建议都会有所帮助。 这是我的代码

<script type="text/javascript" src="jquery/jquery.js"></script>
<link rel="stylesheet" href="jquery/themes/custom-theme/jquery.ui.all.css">
<script src="jquery/ui/jquery.ui.core.js"></script>
<script src="jquery/ui/jquery.ui.widget.js"></script>
<script src="jquery/ui/jquery.ui.datepicker.js"></script>
<script src="jquery/ui/jquery.ui.datepicker-de.js"></script>
<script>
// Please add here the days you want to avoid shipping cakes, like new year, etc.
natDays = [
[1, 2, 'new year'], [6, 7,], [8, 15,], [10, 26,], [11, 1,], [12, 8,],
// [1, 26, 'au'], [2, 6, 'nz'], [3, 17, 'ie'],
//  [4, 27, 'za'], [5, 25, 'ar'], [6, 6, 'se'],
// [7, 4, 'us'], [8, 17, 'id'], [9, 7, 'br'],
//[10, 1, 'cn'], [11, 22, 'lb'], [12, 12, 'ke']
];

function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
  if (date.getMonth() == natDays[i][0] - 1
      && date.getDate() == natDays[i][1]) {
    return [false, natDays[i][2] + '_day'];
  }
}
 return [true, ''];
}


function noWeekendsOrHolidays(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
    return nationalDays(date);
} else {
    return noWeekend;
}
}


$(document).ready(function(){   
$(function() {
    $( "#datepicker" ).datepicker({
        showOn: "button",
        buttonImage: "jquery/calendar.gif",
        buttonImageOnly: true,  
        gotoCurrent: true,
        minDate: +9,
        beforeShowDay: noWeekendsOrHolidays,
        regional: "DE" 
    });
    //$( "#datepicker" ).datepicker.regional['de'];
});


$("#shipping").change(function() {

    if( $('#shipping option:selected').text() == 'Deutschland' ){
        $( "#datepicker" ).datepicker( 'option' , 'minDate' , '+9' );
        $( "#datepicker" ).datepicker( 'setDate' , null );
    }
    else{
        $( "#datepicker" ).datepicker( 'option' , 'minDate' , '+4' );
        $( "#datepicker" ).datepicker( 'setDate' , null );
    }
});

// And now fire change event when the DOM is ready
// $('#shipping').trigger('change');
 });
 </script>

1 个答案:

答案 0 :(得分:1)

虽然评论回答了这个问题,但这有一个答案:

如果遇到数组中的尾随逗号,则Internet Explorer javascript会中断,请将其删除。