In the project I'm working on part the URL fragment is used to update the view. But if the view is updated by the URL fragment the vertical anchor position is lost.
Is there an official way to format a URL fragment to contain a view and anchor? Or does the browser already have support for something like what I'm asking about?
If not is there any reason not to use something like the following?
Example
Current Standard Fragment
https://www.example.com/page.html#anchorOnThePage
Goes to the page and then scrolls into view an anchor named anchorOnThePage
Current with SPA or PWA:
https://www.example.com/page.html#view1
Goes to the page and then displays a view named view1
Desired:
https://www.example.com/page.html#view1:anchorOnThePage
Goes to the page and then displays a view named view1
and then scrolls into view anchorOnThePage
.
Feedback is welcome but for the time being the hash fragment is primarily what I have to work with.
I could use something like this:
https://www.example.com/page.html#view=view1&anchor=anchorOnThePage
https://www.example.com/page.html#view:view1&anchor:anchorOnThePage
But it might look cleaner with a simple separator like a colon or period, go to the view (first index) and then go to the anchor if it exists (second index).
https://www.example.com/page.html#view1:anchorOnThePage
https://www.example.com/page.html#view1.anchorOnThePage
Update:
I would like to use path more and there was a recommendation about this a while ago I think in Google's deep linking guide.
The suggestion was something like this http://www.example.com/page.html/view/post/id/101
. I think WordPress does this.
BUT someone made a fuss about it and they dropped it. I don't remember all the details hence this post.