How to Reset Your HTML5 Game
Of course, if your HTML5 game can stop, you need a way to restart it. The easiest way is to use a dirty trick. Because the game is in a web page, all you have to do is refresh the web page in the browser, and the game will restart.
Add a button to your page.
Use an ordinary HTML button to trigger the reset. If you want, you can position the button with CSS to appear exactly where you want it to be. (Use position: absolute along with the left and top attributes to set the position of your button.)
Tell the button to call the restart() function.
Build a restart() function.
Of course, if you’re going to call a restart() function, you need to create it.
Reload the current document.
Set document.location.href to nothing.
If you set the document.location.href attribute to the empty string (“”) you will in effect reload the current page. This is the easiest way to restart the game.