View Full Version : Javascript to return to previous page

01-12-2012, 05:05 AM
I tried to use the script to return the user to the previous page by clicking the link, and it did work, however, it would return me to the previous website I visited and not just the previous page within my site. Is there a way to override it by changing the code or is the code definitive?

This was the code I had tried to use:

<a href="javascript:history.go(-1)">Back</a>

01-12-2012, 09:09 AM
That code will return the person to whichever page they were on before the current one regardless of what site it is on. It will only send them to a different site if this is the first page of your site they have visited. It literally takes them back to the last page loaded in the browser history regardless of what page it is.

If you want the link to send them to a page on your site then simply code the link to point to that page.