-1

I've build a small form button but somehow I can't get the link to open in a new tab. I've tried the target blank attribute but no results. I've also tried changing onclick="window.location.href to onclick="window.open.href but nothing seems to work.. Here is the HTML:

    <form>
<input style="width: 100%;
min-width: 50px;
max-width: 300px;
 padding: 20px;
 cursor: pointer;
 box-shadow: 6px 6px 5px; #999;
 -webkit-box-shadow: 6px 6px 5px #999;
 -moz-box-shadow: 6px 6px 5px #999;
 font-weight: bold;
 background: #9b5103;
 color: #000;
 border-radius: 2px;
 border: 1px solid #999;
 font-size: 150%;" type="button" value="Kayak Tarifa" onclick="window.location.href='https://stackoverflow.com/'" />
</form>

</body>
Jeroen
  • 11
  • 6

2 Answers2

1

Use window.open()

onclick="window.open('https://stackoverflow.com/')"

working demo : https://jsfiddle.net/gaq23jbL/1/

Rahul
  • 2,374
  • 2
  • 9
  • 17
0

Use onclick="window.open('https://stackoverflow.com/', '_blank');" instead

input {
  width: 100%;
  min-width: 50px;
  max-width: 300px;
  padding: 20px;
  cursor: pointer;
  box-shadow: 6px 6px 5px #999;
  -webkit-box-shadow: 6px 6px 5px #999;
  -moz-box-shadow: 6px 6px 5px #999;
  font-weight: bold;
  background: #9b5103;
  color: #000;
  border-radius: 2px;
  border: 1px solid #999;
  font-size: 150%;
}
<form target="_blank">
  <input style="" type="button" value="Kayak Tarifa" onclick="window.open('https://stackoverflow.com/', '_blank');" />
</form>
Carl Binalla
  • 5,393
  • 5
  • 27
  • 46
  • Accept the answer that works for you so that other users visiting here will immediately know what is the working answer – Carl Binalla Jun 09 '17 at 07:20