如何使用带有查询字符串并着重于元素的URL? [英] How to have a URL With a Query String and Focuses on Element?

查看:43
本文介绍了如何使用带有查询字符串并着重于元素的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在URL中,您可以通过附加'#'及其ID来关注特定元素.例如:

In the URL, you can focus on a particular element by appending a '#' and its id. For example:

http://stackoverflow.com?#footer

上面的代码将自动将您聚焦于ID为页脚"的元素.现在,如果我想在其中包含查询字符串怎么办?像这样:

The code above will auto-focus you to the element with the id "footer". Now what if I would like to include a query string along with it? Like this:

http://stackoverflow.com?#footer&id=3
http://stackoverflow.com?&id=3#footer
http://stackoverflow.com?#footer+id=3
http://stackoverflow.com/#footer?id=3

以上所有URL似乎都不起作用.什么是正确的网址?

None of those URLs above seem to work. What's the correct URL?

推荐答案

正确的语法是:

http://stackoverflow.com?id=3#footer

#之后的所有内容都是客户端内容,这就是为什么它排在最后.

Everything after the # is client-side, which is why it comes last.

如果这不起作用,您将需要发布更多代码,因为问题将出在如何处理查询字符串参数和/或HTML中是否包含锚点上.

If this does not work, you would need to post more of your code, as the problem would then be with how you are handling the query string parameter and/or whether you have the anchor in your HTML.

这篇关于如何使用带有查询字符串并着重于元素的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆