当跳转到 JSP 上的 anchor 时,HTML anchor 不起作用。例如,类似
<a href="#name">Link</a>
...
<div id="name"></div>
失败是因为服务器实际查找名为“filename.jps#name”的文件并返回错误。有什么解决方法吗?
最佳答案
你描述的是一个fragment identifier并且目标可以是命名 anchor 或标识元素,例如
<a href="#foo">go to foo</a>
<a name="foo">foo</a>
<div id="foo">foo</div>
在 this demo 中展示了命名的 anchor 变体
另请注意 HTML5 specification已弃用 a
元素的 name
属性已被删除,因此 id
将是唯一有效的 HTML5 方式 navigate to a fragment identifier .
关于html - 跳转到 JSP 中的 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8044365/