Is it possible for password page to link to a page section?

I’d like for the password page to link to a section of the password-protected page. When the password is cached the “enter password” link goes to the section as intended. When the password needs to be entered, the URL when on the password page shows the section link (/work#case-studies), but then when the password is entered the section link in the URL is removed (/work) and it just goes to the top of the page. Any help would be greatly appreciated.

I was able to figure out a solution. In case it can help anyone else, I used the following custom code on the password protected page:

<script type="text/javascript">
if (location.href = "[my-URL]/work#case-studies") {
  location.replace(“[my-URL]/work#case-studies");
}
</script>

[my-URL] should be replaced with the actual URL, as should page and section ID part that follows.

I still don’t understand why the section ID was being removed when the password was entered, but I think this works because it’s saying if you came from the password page (has URL with section ID) then replace with URL with section ID (getting around it being removed).

I have a very limited understanding of Javascript – if anyone can explain better than me or has a better solution, please share!