gpt4 book ai didi

javascript - GIF 图像在 "document.location.href"时停止

转载 作者:行者123 更新时间:2023-12-04 01:28:03 27 4
gpt4 key购买 nike

我在 javascript 中有这个函数:

function loadPage (url){
showLoadPageGif(); // visibility On
document.location.href = getPath + "/" + url ;
}

当我使用此功能时,GIF 图像显示在屏幕上但不起作用。有人以前打过这个问题吗?谢谢

最佳答案

我最近在使用动画 SVG 作为伪元素中的背景图像时遇到了这个问题。我故意在我的网络服务器上设置了很大的延迟,这样我就可以在 window.location = url; 之后停留在当前页面;奇怪的是,所有其他 CSS 动画和悬停仍然有效,但 SVG 齿轮只是卡住了。

经过一番尝试后,我发现如果我没有更改 window.location,而是提交了 GET 表单,动画会继续运行。

var url;
//load & setup loading animation
//then generate and submit form with a slight delay
setTimeout(function(){
var new_form;
new_form = document.createElement('form');
new_form.method = 'GET';
new_form.action = url;
document.body.appendChild(new_form);
new_form.submit();
}, 100)

在 safari 5.1、firefox 24、chrome 32 上测试

关于javascript - GIF 图像在 "document.location.href"时停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14773005/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com