Reputation: 2650
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?
Upvotes: 0
Views: 768
Reputation: 2035
If I understand your question correctly, you can just do this when the button click:
<script>
function goBack()
{
window.history.go(-2)
}
</script>
<body>
<button onclick="goBack()">Go Back 2 Pages</button>
</body>
This was directly from example of w3school http://www.w3schools.com/jsref/met_his_go.asp
Upvotes: 1
Reputation: 71
How about setting cookie containing the value of referring URL upon entering the registration page, and then using this value to redirect upon leaving the 'Thank you' page?
Upvotes: 1