Javascript: how to use history back() method

[php]
<html>
<head>
<script type="text/javascript">
function goBack()
{
window.history.back()
}
</script>
</head>
<body>

<input type="button" value="Back" onclick="goBack()" />

</body>
</html>
[/php]