如何使用两个按钮将一个 html 页面重定向到另外两个 html 页面?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17921779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to redirect a html page to two other html pages using two buttons?
提问by Vbabey
I can connect to another html page by using the following code by using a button click.
我可以使用以下代码通过单击按钮连接到另一个 html 页面。
<form action="where-you-want-to-go"><input type="submit"></form>
but I have a problem. When there are two buttons on the page how can I redirect them to two different pages by using this code? Or is there any other way to do that?
但我有一个问题。当页面上有两个按钮时,如何使用此代码将它们重定向到两个不同的页面?或者有没有其他方法可以做到这一点?
回答by AnaMaria
YOU COULD DO something like this
你可以做这样的事情
<input type="button" onclick="window.location = 'where-you-want-to-go';">
<input type="button" onclick="window.location = 'where-you-want-to-go';">
回答by Berlin
What do you mean by "redirect"? After clicking submit button the form data is send to action url. If you want you can create two forms:
“重定向”是什么意思?单击提交按钮后,表单数据将发送到操作 url。如果需要,您可以创建两种形式:
<form action="action-first"><input type="submit"></form>
<form action="action-second"><input type="submit"></form>
But if you don't want to send data, you can use links to go to the page:
但是如果你不想发送数据,你可以使用链接去页面:
<a href="/action-first">First link</a>
<a href="/action-second">Second link</a>