动画 gif 不再在 jquery .show() 上动画

发布于 2024-10-28 01:14:27 字数 317 浏览 5 评论 0原文

据我所知,这只影响 IE 8。

使用以下代码,gif 会出现但不是动画(卡在一个位置):

$("#<%=assessmentListLinkClientID() %>").click(function(){
        $("#assessmentListLoaderImg").show();
    });

我还使用了 .css('display', 'block') 具有相同的结果。

是否有一种可接受的方法(也许比这更好)可以产生可靠的跨浏览器结果来显示动画 gif?

As far as I can tell this only affects IE 8.

Using the following code, the gif appears but is not animated (stuck in one position):

$("#<%=assessmentListLinkClientID() %>").click(function(){
        $("#assessmentListLoaderImg").show();
    });

I've also used .css('display', 'block') with the same results.

Is there an accepted way (perhaps better than this) that produces reliable cross-browser results for showing an animated gif?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江挽川 2024-11-04 01:14:27

看来这是解决这个问题的方法:

<div id='myHiddeDiv' style='display:none'> 
<img src='' id='myAnimatedImage'> 
</div> 
<input type='button' value='show image' onclick='showDiv();'> 

<script languag='javascript'> 
function showDiv() 
{ 
document.getElementById('myHiddeDiv').style.display =""; 
document.getElementById('myAnimatedImage').src = "http://www.nowhere.com/animatedGif.gif"; 
} 
</script> 

您需要重新设置图像标签的 src,这迫使 IE 再次渲染它,从而显示它动画。

It appears this is the way to solve this issue:

<div id='myHiddeDiv' style='display:none'> 
<img src='' id='myAnimatedImage'> 
</div> 
<input type='button' value='show image' onclick='showDiv();'> 

<script languag='javascript'> 
function showDiv() 
{ 
document.getElementById('myHiddeDiv').style.display =""; 
document.getElementById('myAnimatedImage').src = "http://www.nowhere.com/animatedGif.gif"; 
} 
</script> 

You need to re-set the src of the image tag, this forces IE to render it again and hence show it animated.

人间不值得 2024-11-04 01:14:27

我不久前遇到了这个问题,虽然我没有解决它,但我最近在 jquery UI 中发现了一些东西,我打算进一步调查。 jQuery UI 引擎中似乎有一个设置可以将内容设置为隐藏在屏幕外,我想知道这是否可以解决 IE 无法正确渲染动画 gif 的问题,因为它们在渲染时不可见。我的理论是,如果它可见但“在屏幕外”,那么 IE 可能会将其渲染为动画,但对用户来说是不可见的。

链接在这里:

http://jqueryui.com/docs/Theming/API

这是我在这里考虑的布局助手:

.ui-helper-hidden-accessible:对元素应用可访问的隐藏(通过页面外的abs定位)

我不能保证这个答案,但它在我的解决方案列表中当我有机会时尝试一下。

如果您尝试此操作并取得任何成功,请告诉我:)

I had this problem a while ago and while I didn't solve it I did spot something in the jquery UI recently that I was going to investigate further. There seems to be a setting in the jQuery UI engine for setting things as hidden off-screen and I was wondering if that might get around the problem with IE not rendering animated gifs properly because they're invisible at render-time. My theory was that if it was visible but "off-screen" then IE might render it as animated but it would be invisible to the user.

The link is here:

http://jqueryui.com/docs/Theming/API

And it's the layout helper here that I'm thinking of :

.ui-helper-hidden-accessible: Applies accessible hiding to elements (via abs positioning off the page)

I can't vouch for this as an answer but it was on my list of solutions to try myself when I had the chance.

If you try this and have any success with it let me know :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文