亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Iframe:設置 document.location 2x 后白屏

Iframe:設置 document.location 2x 后白屏

浮云間 2023-08-05 20:43:26
我正在創建一個 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">
查看完整描述

1 回答

?
楊魅力

TA貢獻1811條經驗 獲得超6個贊

我通過將 document.location 更改為 window.top.location 解決了我的問題

但是,由于我需要將其嵌入到我的網站中,因此每當(畢竟是 window.top)、每當單擊“導航”按鈕時,它都會打開一個新窗口 - 它不會按預期工作,但作為臨時修復,它會做


查看完整回答
反對 回復 2023-08-05
  • 1 回答
  • 0 關注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號