Javascript/jQuery:是否有人已经使用 jquery 在页面顶部 100%:100% 创建了加载固定 div?

发布于 2024-08-20 01:55:13 字数 506 浏览 2 评论 0原文

我有时使用 javascript onload & 的“加载”方法onunloadbody events.(www.restaurantabarocortico.com)

现在我正在学习 jQuery,我使用了 $(document).ready & $(window).unload 替换旧事件,但 unload 事件无法正常工作。 有谁知道另一种在卸载时调用函数的方法?并且,如果需要,可以提供一种方法来中断卸载并执行一些效果(我将需要它来放置一个在卸载时显示加载 div 的效果)。

加载 div 的流程:

  • 它出现在所有内容的顶部(无效果),中间有一个 ajax-loader gif。
  • 当文档准备好时,用jQuery函数隐藏它(慢效果)
  • 当文档/窗口卸载时,用jQuery函数显示它(再次慢效果),并中断一段时间的事件(或休眠效果的时间)。

谢谢,抱歉我的英语:P 何塞·莫雷拉

i used sometimes a 'loading' method with the javascript onload & onunloadbody events.(www.restaurantebarocortico.com)

Now i'm learning jQuery, and i used the $(document).ready & $(window).unload to replace the old events, but the unload event isn't working correctly.
Does anybody knows another method to call a function on unload? And, if needed, a method to break the unload and do some effect (, i will need this to put an effect showing the loading div on unload).

the flow of the loading div:

  • it appears on the top of everything (without effect) with an ajax-loader gif at the middle center.
  • when document is ready, hide it with jQuery function (slow effect)
  • when document/window is unloading, show it with jQuery function (slow effect again), and break for a while the event (or sleep the time of the effect).

Thanks and sorry my english :P
José Moreira

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

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

发布评论

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

评论(1

萌能量女王 2024-08-27 01:55:13

您无法阻止 unloadbeforeunload 事件。如果可以的话,人们会滥用它来使选项卡无法关闭。

You cannot prevent an unload or beforeunload event. If you could, people would abuse it to make tabs unclosable.

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