我在jsFiddle上有这个代码。 http://jsfiddle.net/crashdesk/GbUZ9/
IE7中出现问题,导致错误:
Object不支持属性或方法'indexOf'
对于我的生活,我似乎无法解决它。
有些javascript专家可以帮助我解决这个问题。
非常感谢, ç
答案 0 :(得分: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');
}
答案 1 :(得分:-1)