繁体   English   中英

链接到HTML页面的特定部分

[英]Linking to a specific part of a HTML page

如何在另一个HTML站点上创建指向较长网页的一部分的链接? 我的问题是,我有两个HTML页面: index.html?Site=Info

当我用#进行“跳转链接”时,它不起作用。 有任何想法吗?

如果要链接的部分已设置片段锚,则片段锚应起作用。

 $(document).ready(function(){ $(".anchor").click(function(e){ $('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top }, 1000); }); }); 
 #top{background-color:red;} #middle{background-color:yellow;} #bottom{background-color:green;} div.block{height:400px;} 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="toppage"></div> <a class="anchor" href="#top"> <div class="arrow-down-light-blue">top</div> </a> <a class="anchor" href="#middle"> <div class="arrow-down-light-blue">middle</div> <a class="anchor" href="#bottom"> <div class="arrow-down-light-blue">bottom</div> </a> <div class="block" id="top">The top <a class="anchor" href="#toppage"> Back to top</a> </div> <div class="block" id="middle">The middle <a class="anchor" href="#toppage"> Back to top</a> </div> <div class="block" id="bottom">The bottom <a class="anchor" href="#toppage"> Back to top</a> </div> 

暂无
暂无

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

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