I'm very new to JavaScript. I'm trying to make an HTML button to do 2 things (at the same time) when clicked:
1) Go back while retaining user inputs (there is a form in the previous page).
2) Go to the top of the previous page.
Here is what I have:
<input type="button" value="Go Back" onclick="javascript:history.go(-1); location.href='#'" />
UPDATE:
<script type="text/javascript">
function goBack() {
window.history.go(-1);
window.location.href = "#";
}
</script>
<input type="button" value="Go Back" onclick="goBack()">
The button does not do anything when clicked though.