css 在iframe中的Google doc表单现在几秒钟后加载,但是如何显示计时器倒计时呢?

3qpi33ja  于 2022-12-20  发布在  Go
关注(0)|答案(1)|浏览(86)

嘿,我已经做了代码来显示iframe谷歌文档形式在我的网站,但没有任何倒计时显示或文字,将详细说明有多少秒离开那里.这里的代码:

<script>
    // function to set the source (src) of the iframe...
    function myframe(){
        var frame = document.getElementById("iframe").src = "google form link";
     }
     // call the function 3 seconds (3000 milliseconds) after page load...
     setTimeout(myframe, 10000);
</script>

<iframe id="iframe" src="" height="2350px" width="100%"></iframe>

有人帮我,并添加行,可以详细说明,请等待...秒左!
我确实试着在我的网站上显示一个谷歌表单,但没有文本或css来详细说明需要多少时间,因为应该有文本显示还剩10秒和9 8 7 6 5 4 3 2 1,然后显示iframe谷歌表单。

snvhrwxg

snvhrwxg1#

像这样?

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <span id="countdown"
      >Please, wait. <label id="seconds"></label>s left.</span
    >

    <iframe
      id="iframe"
      src=""
      style="display: none"
      height="2350px"
      width="100%"
    ></iframe>

    <script>
      let secondsToWait = 10;
      document.getElementById("iframe").src =
        "https://jsonplaceholder.typicode.com/";

      const intervalId = setInterval(() => {
        document.getElementById("seconds").innerHTML = secondsToWait--;

        if (secondsToWait == 0) {
          clearInterval(intervalId);
          document.getElementById("iframe").style.display = "block";
          document.getElementById("countdown").style.display = "none";
        }
      }, 1000);
    </script>
  </body>
</html>

相关问题