2017-06-02 43 views
-2

所以我只是把一個按鈕,我不知道如何分配給它的東西。 我的意思是像我點擊另一個鏈接打開的按鈕。如何讓一個按鈕打開一個鏈接

我的按鈕代碼

<input type="button" value="anything"> 
+0

...您的按鈕代碼? – TheDarkKnight

+0

@TheDarkKnight sry我把它 –

+1

歡迎來到Stackoverflow請在發佈問題之前閱讀此問題:https://stackoverflow.com/help/how-to-ask – JazzCat

回答

0

如果你想簡單地做一個按鈕鏈接到其他網站/頁,在這裏你去:

<button onclick="location.href='link_goes_here'" type="button"> 
Button_Text_Here</button> 

音符所使用的不同的引號: )

編輯:

<input type="button" onclick="location.href='link_goes_here'" value="button_text> 
+0

Thx很多沒關係 –

+0

@YashrajSingh我已經在添加你的代碼後編輯代碼。檢查並接受,如果它的工作:) – TheDarkKnight

0

,你可以使用類似的<a href="the_url_where_to_go">text</a>,那麼你用CSS格式化像

a { 
    display:block; 
    width: 100px; 
    height: 30px; 
    background-color: #ccc; 
    border-radius: 5px; 
} 

否則,您可以使用該按鈕使用JavaScript

<button onclick="location.href='the_url_where_to_go'" type="button"> 
Button_Text_Here</button> 

<input type="button" onclick="location.href='the_url_where_to_go'" value="text_of_the button"> 
0

這樣做:

<button onclick="window.open('https://example.com')">Button</button>

0

您可以做

<input type="button" value="Anything" onclick="window.location='http://www.example.org'" />

<a href="http://www.example.org"><button>Anything</button></a>

0

您可以使用<a>標籤和一個按鈕。很簡單。

<a href="http://www.stackoverflow.com"><button>Click this link</button></a> 
相關問題