I'm developing a registration form that leads users to a "Thank you" confirmation page. On this confirmation page, I'd like to have a button that redirects users to wherever they were prior to the registration page.
The only catch is that my client needs this to be done entirely on the front-end, with HTML5 and JavaScript.
Given these constraints, what's the most efficient way to generate a link that sends the user to where he/she was two pages ago?