Jquery 动画在 ie8 中冻结

发布于 2024-10-31 20:19:21 字数 368 浏览 0 评论 0原文

我有一些 JQueryUI 动画和一些 Jquery 代码,这些代码向页面添加了一些 html。 html 是根据 JQuery Ajax 调用的数据生成的。

我认为我的动画冻结可能来自 Ajax 调用,但从下面的问题来看,我认为不是:

为什么我的旋转器 GIF 在 jQuery ajax 调用运行时停止?

我认为我遇到的问题可能是同一原因,但是上面的问题提供了该行为的原因,而不是解决方案。

有人有解决办法吗?

I have some JQueryUI animation coupled with some Jquery code that addes some html to the page. The html is generated based on data from a JQuery Ajax call.

I thought the freezing of my animations might be from the Ajax call, but from what the question below is saying i'm thinking not:

Why does my spinner GIF stop while jQuery ajax call is running?

I think the issue I am having may be of the same origin, however the question above provides a REASON for the behavior, not a SOLUTION.

Does anyone have a solution?

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

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

发布评论

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

评论(2

黯然 2024-11-07 20:19:21

这篇文章 可能对您有帮助。

HTML元素的关键部分如下:

<span id='myHiddenDiv' style='display: none'>
  <img src='' id='myAnimatedImage' align='absmiddle'>
</span>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" OnClientClick="showDiv();" Text="Search" />

我们有一个隐藏的跨度(它可以是一个 div,如果你想将它放在一个新行上),这个跨度内是我们的 img 标签。接下来,在按钮的 OnClientClick 处理程序中,我们调用“showDiv();”客户端脚本函数如下所示:

<script language='javascript'> 
  function showDiv() 
  {
    document.getElementById('myHiddenDiv').style.display =""; 
    setTimeout('document.images["myAnimatedImage"].src="work.gif"', 200); 
  } 
</script>

这里使用setTimeout方法让DOM在200ms后重置图像的src属性。结果是,当您按下启动长时间运行的方法的按钮时,图像将显示并继续动画,直到回发返回并重新加载页面,然后图像消失 - 这正是我们想要的行为。

This article could be of assistance for you.

The key part of the HTML elements is as follows:

<span id='myHiddenDiv' style='display: none'>
  <img src='' id='myAnimatedImage' align='absmiddle'>
</span>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" OnClientClick="showDiv();" Text="Search" />

We have a hidden span (it could be a div, if you want it on a new line), and inside this span is our img tag. Next, in the OnClientClick handler of our button, we call the "showDiv();" client script function which looks like so:

<script language='javascript'> 
  function showDiv() 
  {
    document.getElementById('myHiddenDiv').style.display =""; 
    setTimeout('document.images["myAnimatedImage"].src="work.gif"', 200); 
  } 
</script>

This uses the setTimeout method to make the DOM reset the src property of the image after 200ms. The result is that when you press your button that kicks off your long - running method, the image will show and continue animating until the postback returns and the page is reloaded, whereupon the image disappears -- exactly the behavior we want.

长亭外,古道边 2024-11-07 20:19:21

所以我认为这个问题有3个主要的“解决方案”;好吧,它们是更多的解决方法。

  1. 您可以删除隐藏动画。仅使用 .hide(),然后在节目中使用一些动画。
  2. 您可以使用隐藏动画的回调方法,然后插入html并显示新的div
  3. 您可以使用不同的浏览器。我只在ie8/firefox/chrome上测试过;但在这种情况下,我不得不建议使用 chrome,因为它能够做到这一点,而且非常漂亮。虽然我通常也会建议使用 Firefox,但在这种情况下,它对这种情况的处理并不比 ie8 好。

当然,我想还有第四种解决方案,那就是直接处理它。

So I think that there are 3 main "solutions" to this problem; well they are more workarounds.

  1. You can remove the hide animation. Use just .hide() and then use some animation on the show.
  2. You can use the callback method of the hideing animation to then insert the html and show the new div
  3. You can use a different browser. I have only tested on ie8/firefox/chrome; but I would in this case have to suggest chrome as it's ability to do this beautifuly is amazing. While I would normally also suggest firefox, however in this case it's handeling of this sitution is no better than ie8's.

And of course I guess there is a fourth solution, which is to just deal with it.

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