Propagate the fragment identifier in *all* versions (not just dev).

In d48b79618d5d9d50032cc1b585b10e9dd6958044, I added the ability
of the apge to track the fragment identifier in the URL so that
switching between version would preserve it.

However, I overlooked the fact that the block of code I used
was only executed when viewing the dev version of the docs.

This commit makes the fragement identifier tracking available
for all version.
Improved the propagation of URL fragment identifiers between versions.

The commit introduced in da114303d06f413bda604b363c64e07c32b6bee0
only worked if the user didn't navigate to another fragment
after the page had loaded.

With this new approach, the fragment is added to the version
swticher at the last moment which ensures it is up-to-date.
Fixed #20747 -- Made the documentation link in the navbar point at the current version.

Thanks to Andy Cottrell for the report.