即使在运行了document.location =“”之后,我怎样才能确保我的GIF保持动画效果

时间:2021-11-18 08:09:13

Take the following HTML:

采用以下HTML:

<img src="/any-animated-gif.gf" alt="" />
<br /><br />
<a href="#" onclick="document.location='/anything-that-takes-a-few-seconds-to-load.html';return false;">Click Here</a>

When I click the link the icon stops.

当我点击链接时,图标停止。

3 个解决方案

#1


http://elliottback.com/wp/animated-gif-stops-javascript-click/

According to that link, reassigning the src of the image tag after you have made the redirect with javascript will keep the image animated. Not sure how this acts in firefox.

根据该链接,在使用javascript进行重定向后重新分配图像标记的src将使图像保持动画。不知道这在firefox中是如何起作用的。

#2


Yes, when the browser is going to a new page, all execution of the existing page stops by design. If you wish the current page to continue to function you need to use AJAX techniques.

是的,当浏览器转到新页面时,现有页面的所有执行都会按设计停止。如果您希望当前页面继续运行,则需要使用AJAX技术。

#3


Why are you using Documnet.Location instead of href?

你为什么使用Documnet.Location而不是href?

You cannot change the browser's behavior. Once its loading a different page the current page will always stop.

您无法更改浏览器的行为。一旦加载了不同的页面,当前页面将始终停止。

#1


http://elliottback.com/wp/animated-gif-stops-javascript-click/

According to that link, reassigning the src of the image tag after you have made the redirect with javascript will keep the image animated. Not sure how this acts in firefox.

根据该链接,在使用javascript进行重定向后重新分配图像标记的src将使图像保持动画。不知道这在firefox中是如何起作用的。

#2


Yes, when the browser is going to a new page, all execution of the existing page stops by design. If you wish the current page to continue to function you need to use AJAX techniques.

是的,当浏览器转到新页面时,现有页面的所有执行都会按设计停止。如果您希望当前页面继续运行,则需要使用AJAX技术。

#3


Why are you using Documnet.Location instead of href?

你为什么使用Documnet.Location而不是href?

You cannot change the browser's behavior. Once its loading a different page the current page will always stop.

您无法更改浏览器的行为。一旦加载了不同的页面,当前页面将始终停止。