2012-01-13 34 views
8

我需要在html頁面中單擊按鈕時打開兩個鏈接。我想通過調用onclick函數並使用Javascript中的createElement創建錨標籤。但如何包含另一個鏈接?有沒有辦法在按鈕標籤中提供href?如何在html中的按鈕標籤內提供href

回答

10

你可以簡單地做到這一點與JavaScript

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

如果你想打開CURREN窗口,其中一個鏈接,你可以通過這個

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

看到替換window.open this link獲取更多信息,

1

您需要使用JavaScript事件來創建pa GE去的地方

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

爲什麼不ü用引導

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

它顯示的鏈接去什麼是HREF

提到的一個按鈕