Hash
This built-in plugin provides hash-based navigation:
- starts Fancybox on page load if a matching element for the URL hash value is found;
- updates URL hash value when navigating through gallery items;
- closes Fancybox if it detects that the user is changing the URL hash (for example, by using the "Back" button in the browser).
The gallery name is used for the URL hash, e.g., the value of the data-fancybox
attribute.
If you are having problems with hash navigation, disable this plugin. Example:
Fancybox.bind("[data-fancybox]", {
Hash: false,
});
Note that it is not possible to make this plugin work perfectly in every scenario. It is easy to make the browser history entries contain several empty entries. This is because, due to privacy restrictions, it is not possible to determine, for example, when a user presses the "back" button in a browser or what the previous page is in the history when a user presses "reload". Therefore, this plugin works by observing events like hashchange
and tries to intelligently guess what exactly the user is doing and what the desired result is.