简体   繁体   English

如何防止跳转链接重新加载同一页面?

[英]How to prevent jumplinks from reloading the same page?

I have a banner that is a video and the JavaScript extension Typed js used on the banner text on my website.我有一个横幅是视频和 JavaScript 扩展 Typed js,用于我网站上的横幅文本。 I placed a jumplink right below the banner for people to automatically scroll down on the next section of the homepage.我在横幅正下方放置了一个跳转链接,以便人们在主页的下一部分自动向下滚动。 The problem is whenever that jumplink is clicked, the video restarts and as well as the JS extension.问题是每当单击该跳转链接时,视频都会重新启动,以及 JS 扩展。 I just want it to scroll without the video restarting again or the JS extension typing out the banner text我只是希望它滚动而不重新启动视频或 JS 扩展输入横幅文本

<div class="section">
  <h1>SouthernLawyers</h1>
  <p><span data-controller="typed-js"></span></p>
  <a class="btn btn-gradient" href="#">Submit</a>

  <div class="video-container">
    <div class="color-overlay"></div>
      <video muted loop autoplay id="myvideo" >
         <source src ="<%= asset_path 'banner_video.mp4' %>" type="video/mp4">
      </video>
  </div>
  <a href="#about" id="down">
    <i class="fa-solid fa-chevron-down blinking"></i>
  </a>
</div>
<div class="container">
<h1 id="about">About us</h1>
<%= "Lorem ipsum dolor sit amet, consectetur adipisicing elit " * 100 %>
</div>

Here ya go.这里是 go。 That should be all you need.这应该就是你所需要的。 If it does not work I would try seeing if the extension you are using might be causing issues.如果它不起作用,我会尝试查看您使用的扩展程序是否会导致问题。

 .box { width: 200px; height: 700px; }.box-one, .box-three { background-color: #ddd; }.box-two { background-color: #000; color: #fff; }
 <ul> <li><a href="#one">One</a></li> <li><a href="#two">Two</a></li> <li><a href="#three">Three</a></li> </ul> <div id="one" class="box box-one">One</div> <div id="two" class="box box-two">Two</div> <div id="three" class="box box-three">Three</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM