我们可以控制“加载"吗?浏览器标签中的图标? [英] Can we control the "loading" icon in the browser tab?

查看:21
本文介绍了我们可以控制“加载"吗?浏览器标签中的图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 jQuery 进行了一系列 AJAX 调用.执行 ajax 调用时,没有视觉指示.通常,如果您单击链接或其他非 ajax 加载,浏览器会在选项卡中显示一个小加载图标.

I have a series of AJAX calls via jQuery. When an ajax call is being performed, there is no visual indication. Normally if you click a link or otherwise some non-ajax load the browser displays a little loading icon up in the tab.

有什么办法可以告诉浏览器在选项卡中显示这个小图标吗?(大约有 30 个这样的调用,所以我希望避免修改每个调用).

Is there any way to tell the browser to display this little icon in the tab? (There are about 30 of these calls so I hope to avoid modifying each one).

推荐答案

不,你不能告诉浏览器这样的事情.

No, you can't tell the browser such a thing.

但是你可以做你自己的加载指示器.在标记中包含一个隐藏元素,然后使用 ajaxStartajaxStop 事件来控制其可见性:

But you can do your own loading indicator. Include a hidden element in your markup, then use the ajaxStart and ajaxStop events to control its visibility:

$("#loading_animation").bind({
    ajaxStart: function() { $(this).show(); },
    ajaxStop: function() { $(this).hide(); }
});

ajaxStart 在没有其他人运行的情况下启动 ajax 请求时由 jQuery 触发;ajaxStop 在 ajax 请求完成时触发,没有其他请求在运行.

ajaxStart is fired by jQuery when an ajax request is started when none others are running; ajaxStop is fired when an ajax request completes are there are no others running.

这篇关于我们可以控制“加载"吗?浏览器标签中的图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆