如何使用按钮链接另一个页面

How to link another page using button?

本文关键字:另一个 链接 何使用 按钮      更新时间:2023-09-26

我已经使用了一个模板从网络登录页面,我不能够弄清楚我如何能将这个页面链接到另一个当一个点击'登录'按钮。我不懂HTML、CSS或JS,所以如果有人能指导我,我会很感激。这是为了明天要交的大学项目。不是我不想学,而是我在做别的事情,结果不太好,所以我不得不开始这个,我只有一天的时间。

我无法将代码粘贴到这里。这里是链接:http://pastebin.com/pPS0Np8A

<input type="button" value="click"  onclick="window.open(&quot;http://www.google.com/&quot;); window.open(&quot;http://www.youtube.com/&quot;);" />

如果按下按钮时只是一个链接,则在按钮周围放置一个<a> -标签,并在href属性内放置Link:

<p><a href="http://www.linkToWhereYOuWantItTo.Go"><input type="submit" value="Sign In"></a></p>

使用harshit的解决方案,我添加了id来恢复CSS属性,但如果CSS值是一个类而不是一个id,只需将id=替换为class=。

 <input type="button" value="click" id="myCssClassId"  onclick="window.open(&quot;http://www.google.com/&quot;); window.open(&quot;http://www.youtube.com/&quot;);" />

所以你是"不能弄清楚我怎么能链接到另一个页面当一个点击'Login'按钮"。

从您提供的登录页面简化,您有以下代码:

<form action="Default5.aspx" method="POST">
    <fieldset>
        <p><label for="email">E-mail address</label></p>
        <p><input type="email"
                    id="email"
                 value="mail@address.com" 
              required="required" />
        </p>
        <p><label for="password">Password</label></p>
        <p><input type="password"
                    id="password"
                 value="password" />
        </p>
        <p><input type="submit" value="Login" /></p>
    </fieldset>
</form>

现在,注意<input type="submit" value="Login" />。单击该按钮后,form将提交其中包含的数据(密码和电子邮件)。

当您提交表单时,表单需要一个地址,它需要将数据发送到该地址。这也是显示的页面("重定向")。您可以简单地使用表单的action属性设置它,它只是一个URL。

只是想为以后的读者纠正一下。

编辑:

所以,举个例子,一个精确的图像搜索在google 上可以像这样工作:
<form method="GET"
      action="http://www.google.com/search"
      target="_BLANK"
    onsubmit="var e = this.getElementsByTagName('input');
              e[1].value= 'isz:ex,iszw:' + e[3].value
                        +       ',iszh:' + e[4].value;
              return true;
             "
><fieldset>
    <input type="hidden" name="tbm" value="isch" />
    <input type="hidden" id="tbs" name="tbs" />
    <p>Search Image: 
       <input type="text" name="q" value="search" />
    </p>
    <p>
       Width: <input type="text" value="32" /> px <br />
       Height: <input type="text" value="32" /> px <br />
       <input type="submit" value="Search" />
    </p>
  </fieldset>
</form>

示例jsFiddle here

此处methodPOST更改为GET。这样,表单中输入的值就会被附加到URL中(这样任何人都可以读取它们)。

最后一个关于如何打开新空白页的示例我添加了target -属性,并将其指向_BLANK

这个例子是故意保持简单的,样式和扩展都是你想要的。