如何在html中的button标签内给出一个href

时间:2012-01-13 07:31:35

标签: javascript html

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

6 个答案:

答案 0 :(得分:10)

您只需使用javascript

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

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

window.location = url1;

答案 1 :(得分:2)

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

请参阅this link了解更多信息,

答案 2 :(得分:1)

您需要使用javascript事件使页面转到某处

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

答案 3 :(得分:1)

您也可以使用

location.href=" ";`

答案 4 :(得分:0)

尝试查看位置对象可以执行的操作=&gt; http://www.w3schools.com/jsref/obj_location.asp 您应该能够加载两个选项卡。

答案 5 :(得分:0)

为什么不使用bootstrap

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

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

中提到的内容
相关问题