-
-
Save mehrshaddarzi/acda366376ea0b559e27dae7845b21d3 to your computer and use it in GitHub Desktop.
Code to navigate to previous page in history if it exists, otherwise go back to a default "back" location.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use: ><a href="list.html" class="js-back">Go back</a> | |
$('.js-back').on('click', function(evt) { | |
if (document.referrer != "") { | |
evt.preventDefault(); | |
history.back(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment