The solution of @luisdmz is the most practical and simple, I recommend that. Another solution may be to use localStorage
. When you click on the link instructions put a flag so that neither page is loading, check if the flag exists and if it does not exist, redirect or return to where it was by history.back()
.
On the index.html
page:
const instructions = document.getElementById('#instructions');
instructions.addEventListener('click', function() {
localStorage.setItem('navigationValid', flag);
});
On page instructions.html
const navigationValid = Boolean(localStorage.getItem('navigationValid'));
if (!navigationValid) {
history.back();
}
localStorage.removeItem('navigationValid');
Instead of a parameter with a deductible name you can use a hash so that the user can not put the parameter in the URL or in the storage.