IE8和jQuery空指针 [英] IE8 and jQuery null pointers

查看:157
本文介绍了IE8和jQuery空指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们:我一直在建立一个带有一些动画翻转的网站,在那里我为背景图像设置动画以产生褪色效果。它在FF3,Safari,chrome中工作正常,但是IE8会抛出undefined is null or not object错误。



全文:

 消息:'undefined'为空或不是对象
行:22
字符:16
代码:0
URI:http://www.philipdukes.co.uk/jquery.bgpos.js


消息:'undefined'为null或不是对象
Line :22
Char:16
代码:0
URI:http://www.philipdukes.co.uk/jquery.bgpos.js

在我的网页标题中,我加载了jquery 1.3.2,然后在错误链接中找到了这个bgpos库,然后我的主页脚本



我随时翻转导航按钮,IE8抛出此错误...



任何帮助将不胜感激:我知道我的代码可能不是最时尚的,所以建设性的批评也是受欢迎的。我想专注于这个错误...



shearn89

解决方案

踩过东西,几乎好像它正在爆炸,因为

  $(item).css({backgroundPosition: '0 -246px'}); 

在您的主页脚本的else子句中不存在。



编辑:刚刚注意到Jitter在上面添加了当没有设置显式值时,IE8可能会返回未定义的背景位置。尝试在else中设置backgroundPosition,看看会发生什么。


hey guys: I've been building a website with some animated rollovers, where I animate the background image to give a colour fade effect. It works fine in FF3, Safari, chrome, but IE8 throws the "undefined is null or not an object" error.

Full text:

Message: 'undefined' is null or not an object
Line: 22
Char: 16
Code: 0
URI: http://www.philipdukes.co.uk/jquery.bgpos.js


Message: 'undefined' is null or not an object
Line: 22
Char: 16
Code: 0
URI: http://www.philipdukes.co.uk/jquery.bgpos.js

In my web page header I load jquery 1.3.2, then this bgpos library, found at the link in the error, then my homepage script.

Anytime I rollover the nav buttons, IE8 throws this error...

Any help would be appreciated: I know my code may not be the most stylish out there, so constructive criticism on that would also be welcome. I'd like to focus on this error though...

shearn89

解决方案

Stepping through things, it almost seems like it's blowing up because

$(item).css({backgroundPosition: '0 -246px'});

doesn't exist in the else clause of your homepage script.

Edit: Just noticed that Jitter added above that "Maybe IE8 returns undefined for background-position when no explicit value is set." Try setting the backgroundPosition in the else and see what happens.

这篇关于IE8和jQuery空指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆