前端的javascript需要javascript托管吗?

前端的javascript需要javascript托管吗?

我的代码中有一些 JavaScript 可以帮助图像滑块,我还有一个连接到 HTML 文件的外部文件可以帮助向上滚动。这一切都在前端,我需要专门获取 JavaScript 托管吗?

let calcScrollValue = () => {
let scrollProgress = document.getElementById("progress");
let progressValue = document.getElementById("progress-value");
let pos = document.documentElement.scrollTop;
let calcHeight =
  document.documentElement.scrollHeight -
  document.documentElement.clientHeight;
let scrollValue = Math.round((pos * 100) / calcHeight);
if (pos > 100) {
  scrollProgress.style.display = "grid";
} else {
  scrollProgress.style.display = "none";
}
scrollProgress.addEventListener("click", () => {
  document.documentElement.scrollTop = 0;
});
scrollProgress.style.background = `conic-gradient(#03cc65 ${scrollValue}%, #d7d7d7 ${scrollValue}%)`;

};

窗口.onscroll = 计算滚动值; 窗口.onload = 计算滚动值;

<div class="slider">
            <div class="slides">
              <!--radio buttons start-->
              <input type="radio" name="radio-btn" id="radio1">
              <input type="radio" name="radio-btn" id="radio2">
              <input type="radio" name="radio-btn" id="radio3">
              <input type="radio" name="radio-btn" id="radio4">
              <!--radio buttons end-->
              <!--slide images start-->
              <div class="slide first">
                <img src="Ac slide(4).png" alt="">
              </div>
              <div class="slide">
                <img src="Ac slide (2).png" alt="">
              </div>
              <div class="slide">
                <img src="a14 (2).png" alt="">
              </div>
              <div class="slide">
                <img src="RIANS.png" alt="">
              </div>
              <!--slide images end-->
              <!--automatic navigation start-->
              <div class="navigation-auto">
                <div class="auto-btn1"></div>
                <div class="auto-btn2"></div>
                <div class="auto-btn3"></div>
                <div class="auto-btn4"></div>
              </div>
              <!--automatic navigation end-->
            </div>
            <!--manual navigation start-->
            <div class="navigation-manual">
              <label for="radio1" class="manual-btn"></label>
              <label for="radio2" class="manual-btn"></label>
              <label for="radio3" class="manual-btn"></label>
              <label for="radio4" class="manual-btn"></label>
            </div>
            <!--manual navigation end-->
          </div>
          <!--image slider end-->

相关内容