Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have a URL With a Query String and Focuses on Element?

Tags:

html

url

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

http://stackoverflow.com?#footer

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

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

like image 282
Marlo C Avatar asked Aug 31 '25 10:08

Marlo C


1 Answers

The correct syntax is:

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

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

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.

like image 69
mayabelle Avatar answered Sep 03 '25 00:09

mayabelle