I have been trying a while to make a game with javascript and html and i wonder is there a way to jump to a another html page when the user clicks on the PLAY button? Also the html page i want to jump to is going to be a loading screen but right now it is just the background of the loading screen. Do you have any tips about making a loading screen? Here is my code so far:
function Game_load() { window.location.href = "file:///home/chronos/u-56f297e83910b0d818c1d4b74fa15ed1c727cc9d/MyFiles/HTML,CSS,JS/loadingscreen.html"; }
body { background-image: url("https://thewallpapers.org/zoom/12916/Vista_Wallpaper_%2811%29.jpg"); } .button_div { text-align: center; } .Play_text { text-align: center; top: 45%; } .play_button { background-color: #4CAF50; /* Green */ border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; position: absolute; top: 50%; } .play_button { border-radius: 4px; }
<img src="https://www.freelogoservices.com/api/main/images/1j+ojl1FOMkX9WypfBe43D6kiP6CqhNGnx7IwXs1M3EMoAJtlSgthPNs8vw8" alt="Logo" width="210" height="140"> <div class="button_div"> <button onclick="Game_load()" class="play_button"> PLAY </button> </div>
Well, you need to clean up a bit of your code. Your function Game_load
should have curly brackets after the init of the function, like that:
function Game_Load(){
window.location.href = "file:///home/chronos/u-56f297e83910b0d818c1d4b74fa15ed1c727cc9d/MyFiles/HTML,CSS,JS/loadingscreen.html";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.