How to get fragment from url?

I tried to get the fragment (i.e. after the character ‘#’) from the url, but I cannot find any key of os.environ? What to do?

You can’t. That part isn’t sent to the server.

The normal use of this is to jump to a specific part of a document. There are other ways it’s used too, but always on the client, never the server.

1 Like

It is not clear for me, because a client has answered in a webpage which does send to my server the url ‘/…/…/…/…?aaa=111&bbb=222&ccc=333’. Thereafter the client got the result webpage with a list of some subgroups with ‘<a íd=“xxx”>,’<a íd=“yyy”>, '<a íd=“zzz”>, etc… When an user had clicked the subgroup ‘yyy’, then the webaddress got the url ‘/…/…/…/…?aaa=111&bbb=222&ccc=333#yyy’. When the user copied that url to another browser, then the fragment will NOT be used. Why not?
Hopefully it will be clear for you.

Because that part is used on the client only. Since you have anchors with those IDs, the browser should load the page, then scroll down to the corresponding anchor - in fact, just like with the example I gave from MDN, where I included a fragment that jumped your view down to the part where it talks about fragments. (Very meta.)

Please send me that example (in JavaScript?), because I do not know what MDN is.

The web site that I linked to in my first post in this thread. Have a read - it’s a very good repository of information about all things relating to the web.

Okay, but I’m still able to get the fragment (if present) from the HTTP request string via the JavaScript. So not in Python!?
If it is not possible, then I wonder me how to call my JavaScript function (which can pass the fragmentstring) in my Python web system (without usage of any framework like Flask and Django).