Is it possible to create a form field which sets itself to the last page visited?

For example: on this page -
if you were to click on a link to this form would javascript be able to set it to the last page visited so that i can tell which page the error was on, reducing this risk of user error when inputting the URL.

Any help would be apprieciated,