我正在創建一個 Web 應用程序,旨在將其嵌入到我的 Wix 網站中。我需要的網絡應用程序基本上可以簡化為一個文本屏幕和一個按鈕來更改屏幕視圖/頁面(顯示的html)。然而,問題是,無論我是從“主頁”還是從“頁面”開始,應用程序都會加載兩個下一個屏幕,并在之后給我一個白屏。我還嘗試了其他更改 url 的選項 - ie等location.href,window.location甚至嘗試通過更改頁面<a href= URL,但問題仍然存在。下面是我的代碼的簡化:頁面 HTML <!DOCTYPE html> <html> <script src="https://apis.google.com/js/platform.js" async defer></script> <head> <base target="_self"> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"> </head> <body> <h1>page page</h1> <button id="pagebtn" class="font-family: Raleway; font-size: 16px; waves-effect waves-light btn-small blue accent-2"><i class="material-icons left">check</i> Navigate to home </button> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script> <script> document.getElementById("pagebtn").addEventListener("click",changepage); function changepage(){ var url_new = "https://script.google.com/macros/s/AKfycbzKN9vYBa1yQguooTnijIipyMdAMbXo7a61wjWHt0ybCynH2bxj/exec?v=home"; document.location = url_new; } </script> </body> </html>主頁 HTML <!DOCTYPE html> <html> <script src="https://apis.google.com/js/platform.js" async defer></script> <head> <base target="_self"> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
Iframe:設置 document.location 2x 后白屏
浮云間
2023-08-05 20:43:26