如何在html中的button标记中提供href

how to give a href inside the button tag in html

本文关键字:href button html 中的      更新时间:2023-09-26

当在html页面中单击按钮时,我需要打开两个链接。我通过调用onclick函数并使用Javascript中的createElement创建锚标记来实现它。但是如何包含另一个链接??有没有办法在按钮标签中提供href??

您只需使用javascript 即可实现

window.open(url1);
window.open(url2);

如果你想在当前窗口中打开其中一个链接,你可以用这个代替window.open

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

有关更多信息,请参阅此链接,

您需要使用javascript事件使页面进入

<input type="button" name="button1" value="Go To Url" onClick="window.navigate('URL')"> 

您也可以使用

location.href=" ";`

试着看看位置对象能做什么=>http://www.w3schools.com/jsref/obj_location.asp您应该能够加载两个选项卡。

为什么不使用引导

 <a href="#" class="btn btn-default">

它显示一个按钮,链接指向href

中提到的内容