<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                前言 在JavaScript中有好幾種方法可以重定向到另一個網頁,這個在項目開發中經常會用到,所以不熟悉的童鞋可以學下啦,首先我們介紹有哪些方法? 如何使用JavaScript重定向到其他網頁? 使用JavaScript重定向到其他網頁的一些方法: location.href location.replace() location.assign() 語法: location.href=“URL”//或者 location.replace(“URL”)//或者 location.assign(“URL”) 參數: 接受單個參數的URL,這是必需的。用于指定新網頁的引用。 返回值: 無返回值。 1 location.href 示例1: 使用location.href屬性重定向到其他網頁: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <p>這是<i>location.href</i>方式的示例</p> <button onclick="myFunc()">點擊這里</button> <!--重定向到其他網頁的腳本--> <script> function myFunc() { window.location.href="https://www.jiangweishan.com"; } </script> </body> </html> ``` 2 location.replace 示例2: 使用location.replace()方法重定向到其他網頁: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <p>這是<i>location.replace()</i>方式的示例</p> <button onclick="myFunc()">點擊這里</button> <!--重定向到其他網頁的腳本--> <script> function myFunc() { location.replace("https://www.jiangweishan.com"); } </script> </body> </html> ``` 3 location.assign 示例3: 使用location.assign()方法重定向到其他網頁: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <p>這是<i>location.assign()</i>方式的示例</p> <button onclick="myFunc()">點擊這里</button> <!--重定向到其他網頁的腳本--> <script> function myFunc() { location.assign("https://www.jiangweishan.com"); } </script> </body> </html> ``` 注意: 所有方法的輸出都相同,但location.replace()方法從文檔歷史記錄中刪除當前文檔的URL。因此,如果希望選項導航回原始文檔,最好使用location.assign()方法。 瀏覽器支持 上述方法的瀏覽器支持列表: Google Chrome Apple Safari Firefox Opera Edge 4 總結 location.href、location.replace() ,location.assign(),是不是覺得很簡單呢?希望對大家有所幫助吧。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看