簡體   English   中英

缺乏編碼經驗,需要幫助添加到 HTML 腳本

[英]Inexperienced to code, need help adding to an HTML script

我通過幫助管理他們剛剛遷移到 Squarespace 的網站來為當地教會做一些志願者工作。 他們想做一些需要代碼注入的高級工作,而我對此幾乎一無所知。 話雖如此,我已經成功復制+粘貼某些代碼,例如我在下面找到的這個 HTML 倒數計時器。 我正在尋找任何能夠幫助我讓這個腳本每周循環播放的人,每周日倒計時到上午 10 點,而不必每周輸入 go 並更改日期。 有沒有人可以在這里幫助我? Squarespace 不支持代碼注入。 謝謝!

*另外,僅供參考,除了 html 之外,注入其他代碼的運氣並不好。 該網站出於某種原因不想接受它。


<!-- Display the countdown timer in an element -->
<p id="demo"></p>

<script>
// Set the date we're counting down to
var countDownDate = new Date("Jan 5, 2022 15:37:25").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

  // Get today's date and time
  var now = new Date().getTime();

  // Find the distance between now and the count down date
  var distance = countDownDate - now;

  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);

  // Display the result in the element with id="demo"
  document.getElementById("demo").innerHTML = days + "d " + hours + "h "
  + minutes + "m " + seconds + "s ";

  // If the count down is finished, write some text
  if (distance < 0) {
    clearInterval(x);
    document.getElementById("demo").innerHTML = "EXPIRED";
  }
}, 1000);
</script>

您希望將countDownDate日期設置為即將到來的第一個星期日。 您可以使用這個答案的解決方案: https://codereview.stackexchange.com/a/33648來找到它。


我不完全確定“注入 html”是什么意思。 您似乎只是在 Squarespace 網站上添加了一些 javascript。 代碼注入是指您將無效數據存儲在程序中以便執行該數據。 有關更多信息,請參閱https://en.m.wikipedia.org/wiki/Code_injection

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM