无法让表单按钮 link 在新 window 中打开
Can't get form button link to open in new window
我已经构建了一个小表单按钮,但不知何故我无法让 link 在新选项卡中打开。我试过目标空白属性但没有结果。我也尝试过更改 onclick="window.location.href to onclick="window.open.href 但似乎没有任何效果。这是 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://whosebug.com/'" />
</form>
</body>
改用onclick="window.open('https://whosebug.com/', '_blank');"
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://whosebug.com/', '_blank');" />
</form>
使用window.open()
onclick="window.open('https://whosebug.com/')"
我已经构建了一个小表单按钮,但不知何故我无法让 link 在新选项卡中打开。我试过目标空白属性但没有结果。我也尝试过更改 onclick="window.location.href to onclick="window.open.href 但似乎没有任何效果。这是 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://whosebug.com/'" />
</form>
</body>
改用onclick="window.open('https://whosebug.com/', '_blank');"
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://whosebug.com/', '_blank');" />
</form>
使用window.open()
onclick="window.open('https://whosebug.com/')"