You need to use javaScript "DOM" facilities.
There are multiple ways to go to the previous page.
You need to look here: (to learn
javaScript [
^] and
DOM[
^]).
As a special treat,
this[
^] gets you to a place that describes one possible route.
You still need to do the work