我正在构建一个带有一些动画翻转的网站,我在其中对背景图像进行动画处理以提供颜色淡入淡出效果。它在 FF3、Safari、chrome 中工作正常,但 IE8 会抛出“未定义为 null 或不是对象”错误。
全文:
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
在我的网页标题中,我加载 jquery 1.3.2,然后加载这个 bgpos 库,在错误中的链接中找到,然后我的主页脚本.
每当我滚动导航按钮时,IE8 都会抛出此错误...
任何帮助将不胜感激:我知道我的代码可能不是最时尚的,所以建设性的对此的批评也将受到欢迎。不过,我想重点关注这个错误。
我遇到了同样的问题,并像这样修改了 jquery.bgpos.js ,现在它可以在 IE 中工作了。
(function($)
{
$.extend($.fx.step,
{
backgroundPosition: function(fx)
{
if (fx.state === 0 && typeof fx.end == 'string')
{
if(navigator.appName == 'Microsoft Internet Explorer')
{
var start = $.curCSS(fx.elem,'backgroundPositionX');
start += ' ';
start += $.curCSS(fx.elem,'backgroundPositionY');
}
else
{
var start = $.curCSS(fx.elem,'backgroundPosition');
}
start = toArray(start);
fx.start = [start[0],start[2]];
var end = toArray(fx.end);
fx.end = [end[0],end[2]];
fx.unit = [end[1],end[3]];
}
var nowPosX = [];
nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
function toArray(strg)
{
strg = strg.replace(/left|top/g,'0px');
strg = strg.replace(/right|bottom/g,'100%');
strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
}
}
});
})(jQuery);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)