The default behaviour of a web page is that the browser displays it "from the top". I can request it to be displayed from a specific bookmark if I set for example the id="my_bookmark"
attribute to an element in the page and then request the URL mywebsite.com/mypage.html#my_bookmark
.
I feel like there has to be a way to change this behaviour so that a page will automatically load at a specified bookmark further down the page, because that seems to me like a no-brainer, yet I can't find anything on that. Maybe I'm looking in the wrong places ?
Specific questions :
- Is there a simple HTML5 way to do this ? Like some sort of
<meta>
tag or other that tells the browser at what bookmark to load a page by default ? - Failing that, I'm curious : how are bookmarks handled at all ? I feel like if they're included in the URL it has to be because the server does something with that information; can I do anything about the bookmarks with PHP ? Or even with the damned
.htaccess
file ? - If this feature doesn't exist anywhere, is there a good reason that I just don't see ? It does seem to me like it's a very straightforward thing.
If you're wondering, my use case is this : I'm making a web-based game that has the player move through a story by solving puzzles. Every so often the player discovers a new "bit" of the story (a couple of new paragraphs). When they do, they are taken to story.php
where all the pieces of the story that they have so far discovered will be displayed, in reading order, from top to bottom. But I want the player to land on story.php
directly at the last bit of the story that they discovered, and I want them to scroll up if they want to read the previous stuff. I feel like that has to be doable, and fairly simple.
The stuff I know : Some HTML5, some CSS, some PHP. I don't really want to use a specific new PHP library if it means I have to install it, and I feel like I want to avoid JavaScript, but maybe you can talk me into it.