2011-10-27 148 views
4

当前正在运行chrome 14,并且它无法在我的登录页面上呈现旋转的gif图形。chrome不呈现gif背景图像

这里是页面的样子铬:

enter image description here

下面是它看起来像所有其他的browers:

enter image description here

重现:

http://trunk.test.openmile.com/login/#null

输入一个有效的电子邮件和密码,然后点击'登录',然后当黑色进度指示器出现时,点击停止,以便浏览器不会有机会给你一个登录错误。

请注意,背景不会显示在镶边中。有趣的是,如果您检查元素,并将1px添加到背景图像位置,图像将变为可见。

闻起来像铬缺陷给我,但有没有解决方法?

编辑: 另一个真是奇怪的是:如果我把一个alert在显示该加工DIV函数的结束,警报后,背景图像变得可见。

回答

5

我可以重现你的问题,但如果我手动触发弹出式控制台,我看到了微调就好:

> OM.processing($('div.portlet.login form')); 

因此,这里是我的猜测 - 你的微调并未预装,和你您在等待AJAX​​请求时打开窗口。无论出于何种原因,其他浏览器都会在AJAX请求未决时加载图片,但Chrome不会。为了测试这个,我在控制台上试了一下:

> var img = $('<img src="http://trunk.test.openmile.com/static/9753/images/processing_black.gif">'); 

然后试图正常登录 - 我看到了微调。

所以我想如果你预先加载你的微调图像,也许用上面的代码,它应该正常工作。

+0

如果你想保留它依赖于CSS,你可能想使用这个'var bg = $(此)的CSS(“背景图像”); bg = bg.replace('url(','')。replace(')',''); var forceChromeToLoadImage = $('');'see http://stackoverflow.com/questions/8809876/can-i-get-divs-background-image-url –

0

我在使用nrabinowitz的答案时遇到了问题。

所以我最终在页面的某个地方包含了相关的图像,并且有0个维度。

HTML:

<input class="button" id="myButton" type="submit" name="searchButton" /> 
... 

<img class="loaderHackForChrome" src="" width="0" heigh="0"> 

的Javascript:

/* 
    Hack for Chrome issue with GIF bg images 
    [1] gets the bg url from the CSS 
    [2] Extract the path: by removing opening string "url(" and closing character ")" that surround it 
    [3] Sets the relevant image tag with our GIF image's path 
*/ 
$('#myButton').click(function() { 
    var bg = $(this).css('background-image'); // [1] 
    bg = bg.replace('url(','').replace(')',''); // [2] 
    $('.loaderHackForChrome').att('src', bg); // [3] 
}); 

来源:http://chromespot.com/forum/google-chrome-troubleshooting/4336-background-image-doesnt-load.html

编辑:这个问题可能已被现在固定在