所以我希望屏幕从一种 HTML 切换到另一种 HTML,这是我的 JS 代码。每当我按下按钮时,屏幕就会变成空白。我正在尝试制作多个 HTML 页面,并在按下按钮时切换到下一个页面。请帮忙JSfunction loadScreen(){ var load = new XMLHttpRequest(); load.onreadystatechange = function() { document.getElementById("firstScreen").innerHTML = this.responseText; } load.open("GET", "SelectNumber.html", true); load.send();}function myFunction(load){ document.getElementById("firstScreen").innerHTML = load.responseText;}原始 HTML<head> <meta charset="UTF-8"> <title>Number Game</title> <link rel = "stylesheet" href = "stylesheet.css"></head><body> <div id = "firstScreen"> <h1 id ="Title" class = "title"> The<br>Number Game </h1> <div class = "start_button"> <h3 class = "start">START <input type = "image" placeholder = "START" src = "button.png" class = "button1" onclick = "loadScreen()"> </h3> </div> </div></body><script src = "Main.js"> </script></html>我试图将其更改为 HTML2<html><head> <meta charset="UTF-8"> <title>Number Game</title> <link rel = "stylesheet" href = "stylesheet.css"></head><body> <div id="Screen2"> <p> Hello World</p> </div> <script src = "Main.js"> </script></body></html>
添加回答
举报
0/150
提交
取消