onClick= "window.location='/viewAllAdmins';"正在提交表单,而不是转发到提供的链接


<table border=0 align=center cellpadding=9>
<tr>
<td>
<button class="font-awesome-btn" onClick="window.location='/viewAllAdmins';"  style="margin:auto; display:block;"><i class="fa fa-arrow-left" aria-hidden="true"></i>  Go Back  </button>
</td>
<td>
<button class="font-awesome-btn"> Submit <i class="fa fa-arrow-right" aria-hidden="true"></i></button>
</td>
</tr></table>

onClick事件提交表单,而不是将我带到提供的URL。

这是因为您的按钮是一个提交按钮,并且您没有抑制它的默认操作。您可以将type="button"设置为简单地解决此问题。


但在这里使用按钮首先是对该元素的"滥用"-如果你只是想链接到其他地方,那么你应该使用链接<a>。如果需要,可以通过CSS将其格式化为,看起来像按钮。

最新更新