-2

So I just put a button and I don't know how to assign things to it. I mean like I click the button the another link is opened.

My button code

<input type="button" value="anything">
DaFois
  • 2,197
  • 8
  • 26
  • 43

5 Answers5

0

If you want to simply make a button link to another website/ page, here you go:

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

note the different quotation marks being used :)

edit:

<input type="button" onclick="location.href='link_goes_here'" value="button_text>
Sreetam Das
  • 3,226
  • 2
  • 22
  • 36
0

you can use something like an <a href="the_url_where_to_go">text</a> then you format it with css like

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

otherwise you can use the button with javascript

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

or

 <input type="button" onclick="location.href='the_url_where_to_go'" value="text_of_the button">
DaFois
  • 2,197
  • 8
  • 26
  • 43
0

Do this:

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

You can either do

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

or

<a href="http://www.example.org"><button>Anything</button></a>
StuntHacks
  • 457
  • 3
  • 15
0

You can just use the <a> tag with a button inside. very simple.

<a href="http://www.stackoverflow.com"><button>Click this link</button></a>
Exil
  • 311
  • 2
  • 11
  • 26