[英]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.