ie9和opera的jquery对象问题

时间:2012-12-29 23:10:05

标签: javascript jquery json datejs

我一直在努力让脚本在我的网站上运行,它适用于Chrome,Safari和Firefox,但不适用于IE 9(它将在兼容模式下工作)或Opera。有没有我没有抓到的问题?

这是脚本:

$(document).ready(function(){
$.getJSON('/storage/xml/biblereading2.json', function(data) {
today = Date.today();
var name = today.getDay();
var date = today.getDate();
var month = today.getMonth();
var year = today.getFullYear();
var fullday = name.toString();
var todaydoy = today.getDayOfYear();
var todaywoy = today.getWeekOfYear();
//array for months
fullmonth = new Array (12);
fullmonth[0] = "January";
fullmonth[1] = "February";
fullmonth[2] = "March";
fullmonth[3] = "April";
fullmonth[4] = "May";
fullmonth[5] = "June";
fullmonth[6] = "July";
fullmonth[7] = "August";
fullmonth[8] = "September";
fullmonth[9] = "October";
fullmonth[10] = "November";
fullmonth[11] = "December";
fullday = new Array (7);
fullday[0] = "Sunday";
fullday[1] = "Monday";
fullday[2] = "Tuesday";
fullday[3] = "Wednesday";
fullday[4] = "Thursday";
fullday[5] = "Friday";
fullday[6] = "Saturday";
var s = todaydoy - 1;
$("#biblereading").append('<p><span class="bold_font">Bible Reading for Today:</span>  </br>' + fullmonth[month] + ' ' + date + ', ' + year + '</br>' + data.schedule[s].portion.reading + '</br></p>');
});
});

我正在使用date.js处理前几个变量中的日期问题,一个数组给出拼写的月份和日期,我从同一个服务器调用json。

Opera一直告诉我,我在data.schedule [s]

上有一个TypeError

并且IE 9一直告诉我在data.schedule [s]上有一个未定义或空值。

任何想法? (您可以在首页上看到此次尝试实施http://rosemontbaptist.com

1 个答案:

答案 0 :(得分:1)

如果您记录今天的内容

var todaydoy = today.getDayOfYear();

您将看到它在IE中返回错误的值,以下内容将从IE9控制台的监视窗口中复制。

todaydoy    694324  Number

您需要弄清楚它们是否是您正在使用的日期库中的错误。