【问题标题】:How do I link two HTML pages with a button? [duplicate]如何用一个按钮链接两个 HTML 页面? [复制]
【发布时间】:2015-10-10 02:26:34
【问题描述】:

我有两个 HTML 页面,一个是应用程序的打开页面,第二个是登录页面。我在打开页面上有一个按钮,我希望能够单击它并让它带我进入登录页面。我该怎么做?

【问题讨论】:

    标签: html button


    【解决方案1】:

    这将添加一个按钮并将其链接到登录页面:

    <a href="path_to_login_page">
      <button>Take me to the login page</button>
    </a>
    

    更改 path_to_login_pageTake me to the login page 以自定义按钮。如果您已经有一个自定义按钮并想使用它:

    <a href="path_to_login_page">
      'Place your button here'
    </a>
    

    【讨论】:

      【解决方案2】:

      就我个人而言,我只是将按钮更改为标准锚。您仍然可以设置链接样式以使其看起来像一个按钮。

      <a href="index.html">Go home</a>
      

      如果元素确实必须保留为按钮,您可以这样做:

      <button onclick="location.href='index.html'>Go home</button>
      

      不过,这并不是最佳实践。

      【讨论】:

        【解决方案3】:

        这是最短且最快的方法:

        <a href="login-page.html">
        <button> Login Page</button>
        </a>
        

        在此处运行并检查:https://jsfiddle.net/2zov6q2v/14/

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-11-29
          • 2018-02-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-11-10
          • 2016-04-21
          • 2021-08-02
          相关资源
          最近更新 更多