gpt4 book ai didi

java - Spring MVC中如何使用anchor标签在当前jsp中找到固定位置?

转载 作者:行者123 更新时间:2023-12-01 11:38:10 26 4
gpt4 key购买 nike

我只想将我的html标签定位在我当前的jsp页面中,这意味着我不需要跳转到 Controller 。现在我使用代码,但它总是跳转到 Controller ,如何更改我的代码?我的网站网址是http://localhost:8888/MySpringMVC/,并且我在顶部有一个名为headdiv的div。当用户单击链接时,我想找到它到headdiv。我当前的网页网址是http://localhost:8888/MySpringMVC/main/index。我想跳转到 http://localhost:8888/MySpringMVC/main/index#top-container

<!--both of ways  jump to http://localhost:8888/MySpringMVC/#top-container-->
<a href="javascript:void(window.location.href='#top-container')">
<a href="#top-container">

最佳答案

您尝试的第二件事应该有效( <a href="#top-container">TEST</a> ),在我的测试中有效,这意味着它可能比您在问题中写的更多。

无论如何,这是一个应该可以工作的小型 JavaScript 解决方案

<a href="" onclick="window.location.hash = 'top-container'; return false;">TEST</a>

关于java - Spring MVC中如何使用anchor标签在当前jsp中找到固定位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29792935/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com