簡體   English   中英

單擊按鈕時如何跳轉到另一個 HTML 頁面

[英]How to jump to another HTML page when clicking on button

我一直在嘗試使用 javascript 和 html 制作游戲,我想知道當用戶單擊“播放”按鈕時有沒有辦法跳轉到另一個 html 頁面? 此外,我想跳轉到的 html 頁面將是一個加載屏幕,但現在它只是加載屏幕的背景。 你有什么制作加載屏幕的技巧嗎? 到目前為止,這是我的代碼:

 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>

好吧,您需要清理一些代碼。 您的函數Game_load應該在函數的 init 之后有大括號,如下所示:

 function Game_Load(){
     window.location.href = "file:///home/chronos/u-56f297e83910b0d818c1d4b74fa15ed1c727cc9d/MyFiles/HTML,CSS,JS/loadingscreen.html";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM