標題是不言自明的。我試圖隱藏一個隱藏的 href,當點擊它時,會擦除頁面上的所有內容,在將統一游戲作為整個頁面插入之前將其留空一秒鐘。
這是我到目前為止所得到的。
<!DOCTYPE html>
<html>
<script>
function wipeHTML() {
document.documentElement.innerHTML = nothing; //NEED HELP HERE
then wait 1 second
document.documentElement.innerHTML = unity game loads; //NEED HELP HERE
}
</script>
<!-- UNITY STUFF -->
<head>
<link rel="stylesheet" href="TemplateData/style.css">
<script src="TemplateData/UnityProgress.js"></script>
<script src="TemplateData/unityloader41.js"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/slope.json", {
onProgress: UnityProgress,
Module: {
onRuntimeInitialized: function() {
UnityProgress(gameInstance, "complete")
}
}
});
</script>
</head>
<body style="margin: 0; overflow: hidden;">
<div class="webgl-content">
<div id="gameContainer" style="width: 100%; height: 100%; margin: 0;"></div>
</div>
</body>
<!-- UNITY STUFF END -->
<h1>
<a href="javascript:wipeHTML">wipe everything</a>
</h1>
<div>
<h1>
hello
</h1>
<h3>
erase me
</h3>
</div>
告訴我我做錯了什么!???♂?
uj5u.com熱心網友回復:
要清除頁面正文:
document.body = document.createElement("body");
要顯示游戲,請添加超時,將 console.log 替換為顯示游戲的代碼。
setTimeout(() => console.log("load unity here"), 5e3)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/355555.html
標籤:javascript html 查询 功能 统一3d
上一篇:無法從API獲取影像以顯示
