[英]How can I make a restrat button in JavaScript?
I have created a simple snake game using html and JavaScript.我使用 html 和 JavaScript 创建了一个简单的蛇游戏。 after the game over you need to press F5(refresh) button on keyboard to restart the game.游戏结束后,您需要按键盘上的F5(刷新)按钮重新启动游戏。 I want to create a button called restart that upon being pressed refreshes the page .我想创建一个名为 restart 的按钮,按下后刷新页面。 How can I do it?我该怎么做?
Add this inside your Restart button to reload the page.将此添加到您的重新启动按钮中以重新加载页面。
window.location.reload();
You should not refresh the page to Restart the Game.您不应刷新页面以重新启动游戏。 This feature should be implemented separately.此功能应单独实现。 Reset all parameters and rerun your game start code again.重置所有参数并再次重新运行您的游戏启动代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.