she*_*n89 3 null jquery pointers internet-explorer-8
嘿伙计们:我一直在建立一个带有一些动画翻转的网站,在那里我为背景图像设置动画以产生褪色效果.它在FF3,Safari,chrome中工作正常,但是IE8会抛出"undefined is null or not object"错误.
全文:
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
Run Code Online (Sandbox Code Playgroud)
在我的网页标题中,我加载了jquery 1.3.2,然后在错误链接中找到了这个bgpos库,然后是我的主页脚本.
每当我翻转导航按钮时,IE8都会抛出此错误...
任何帮助将不胜感激:我知道我的代码可能不是最时尚的,所以建议性的批评也是受欢迎的.我想专注于这个错误...
shearn89
小智 11
我遇到了同样的问题并修改了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);
Run Code Online (Sandbox Code Playgroud)