HTML 中实现页面跳转有多种方法,以下是几种常见的方式:

  1. 使用超链接 <a> 标签:

    <a href='目标页面的URL'>链接文本</a>
    
  2. 使用表单提交:

    <form action='目标页面的URL' method='post'>
      <!-- 表单元素 -->
      <input type='submit' value='提交'>
    </form>
    
  3. 使用JavaScript的 window.location.href 方法:

    <script>
      function redirectTo(url) {
        window.location.href = url;
      }
    </script>
    
    <button onclick='redirectTo('目标页面的URL')'>跳转</button>
    
  4. 使用JavaScript的 window.location.replace 方法:

    <script>
      function redirectTo(url) {
        window.location.replace(url);
      }
    </script>
    
    <button onclick='redirectTo('目标页面的URL')'>跳转</button>
    

注意:在实际使用中,需要将 '目标页面的URL' 替换为要跳转到的页面的实际URL。


原文地址: https://www.cveoy.top/t/topic/pA5Z 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录