<legend id='6ubSf'><style id='6ubSf'><dir id='6ubSf'><q id='6ubSf'></q></dir></style></legend>
      <i id='6ubSf'><tr id='6ubSf'><dt id='6ubSf'><q id='6ubSf'><span id='6ubSf'><b id='6ubSf'><form id='6ubSf'><ins id='6ubSf'></ins><ul id='6ubSf'></ul><sub id='6ubSf'></sub></form><legend id='6ubSf'></legend><bdo id='6ubSf'><pre id='6ubSf'><center id='6ubSf'></center></pre></bdo></b><th id='6ubSf'></th></span></q></dt></tr></i><div id='6ubSf'><tfoot id='6ubSf'></tfoot><dl id='6ubSf'><fieldset id='6ubSf'></fieldset></dl></div>
      1. <small id='6ubSf'></small><noframes id='6ubSf'>

      2. <tfoot id='6ubSf'></tfoot>

        • <bdo id='6ubSf'></bdo><ul id='6ubSf'></ul>

        window.setTimeout() 在 Safari 中的页面导航后停止

        时间:2023-10-04
          <bdo id='lXyDx'></bdo><ul id='lXyDx'></ul>
          <legend id='lXyDx'><style id='lXyDx'><dir id='lXyDx'><q id='lXyDx'></q></dir></style></legend>

              <i id='lXyDx'><tr id='lXyDx'><dt id='lXyDx'><q id='lXyDx'><span id='lXyDx'><b id='lXyDx'><form id='lXyDx'><ins id='lXyDx'></ins><ul id='lXyDx'></ul><sub id='lXyDx'></sub></form><legend id='lXyDx'></legend><bdo id='lXyDx'><pre id='lXyDx'><center id='lXyDx'></center></pre></bdo></b><th id='lXyDx'></th></span></q></dt></tr></i><div id='lXyDx'><tfoot id='lXyDx'></tfoot><dl id='lXyDx'><fieldset id='lXyDx'></fieldset></dl></div>

                • <tfoot id='lXyDx'></tfoot>
                • <small id='lXyDx'></small><noframes id='lXyDx'>

                    <tbody id='lXyDx'></tbody>

                  本文介绍了window.setTimeout() 在 Safari 中的页面导航后停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个页面需要 8 到 10 秒才能加载,因为服务器对外部服务进行 API 调用,从而处理一些大数字.这在提交表单后调用.

                  I have a page that takes 8-10 seconds to load, as the server makes an API call to an external service which crunches some big numbers. This is called after submitting a form.

                  最初,我在叠加层中展示了一个 CSS 加载动画,以向用户展示页面实际上在做什么.

                  Initially, I showed a CSS loading animation in an overlay to show the user the page is actually doing something.

                  然后我通过使用 window.setTimeout() 每 2 秒调用一些代码来增强它,更新进度条并显示一条消息,说明系统正在做什么.这当然是假的,但是当 10 秒内要阅读 4-5 条消息时,它使时间看起来要短得多.

                  I then augmented this by calling some code every 2 seconds with window.setTimeout(), updating a progress bar and showing a message saying what the system is doing. It's fake, of course, but it makes the time seem much shorter when there's 4-5 messages to read in 10 seconds.

                  我的问题是超时在 Safari(MacOS 或 iOS 上)中不起作用.它适用于所有其他浏览器,包括 Mac 上的 Chrome.提交表单后,所有计时器似乎都停止了(它也会影响横幅中的幻灯片)

                  My problem is the timeout isn't working in Safari (on MacOS or iOS). It works in all other browsers, including Chrome on the Mac. As soon as the form is submitted, all timers seem to be halted (it also affects the slideshow in the banner)

                  有没有人遇到过这种情况并知道解决方法?我真的不想用 AJAX 替换标准表单提交,因为这会涉及到我们没有预算的相当多的重组.

                  Has anyone encountered this, and know of a workaround? I don't really want to have to replace the standard form submission with an AJAX one as that would involve quite a bit of restructuring which we don't have budget for.

                  推荐答案

                  我知道这是一个非常具体的用例,但我最终使用 CSS 动画(带有关键帧)而不是 setTimeout() 来允许动画在之后运行已经开始导航了.

                  I know it's a very specific use case, but the I ended up using CSS animations (with keyframes) instead of setTimeout() to allow the animation to run after the navigation away has started.

                  我偶然发现,一旦页面请求开始,Safari 中的大多数动画属性似乎都不起作用,但任何转换"属性都可以.也许这是一个 Safari 错误,我不确定.

                  I stumbled across the fact that most animated properties in Safari don't seem to work once the page request has started, but any "transform" ones do. Maybe this is a Safari bug, I'm not sure.

                  所以我用 translateY 代替了top",用 scaleX 代替了 width.

                  So instead of "top" I used translateY, and instead of width I used scaleX.

                  这篇关于window.setTimeout() 在 Safari 中的页面导航后停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 iPhone X 系列上处理 Chrome 浏览器中的安全区域 下一篇:如何从 Android 的 WebView 中的 javascript 获取返回值?

                  相关文章

                  1. <small id='AOyqq'></small><noframes id='AOyqq'>

                    <tfoot id='AOyqq'></tfoot>
                      <bdo id='AOyqq'></bdo><ul id='AOyqq'></ul>

                      <legend id='AOyqq'><style id='AOyqq'><dir id='AOyqq'><q id='AOyqq'></q></dir></style></legend>
                    1. <i id='AOyqq'><tr id='AOyqq'><dt id='AOyqq'><q id='AOyqq'><span id='AOyqq'><b id='AOyqq'><form id='AOyqq'><ins id='AOyqq'></ins><ul id='AOyqq'></ul><sub id='AOyqq'></sub></form><legend id='AOyqq'></legend><bdo id='AOyqq'><pre id='AOyqq'><center id='AOyqq'></center></pre></bdo></b><th id='AOyqq'></th></span></q></dt></tr></i><div id='AOyqq'><tfoot id='AOyqq'></tfoot><dl id='AOyqq'><fieldset id='AOyqq'></fieldset></dl></div>