我已经构建了一个小表单按钮,但不知怎的,我无法在新选项卡中打开链接。我已经尝试了目标空白属性,但没有结果。我也尝试将onclick =“window.location.href更改为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://stackoverflow.com/'" />
</form>
</body>
答案 0 :(得分:1)
使用window.open()
onclick="window.open('https://stackoverflow.com/')"
答案 1 :(得分:0)
使用onclick="window.open('https://stackoverflow.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%;
}
&#13;
<form target="_blank">
<input style="" type="button" value="Kayak Tarifa" onclick="window.open('https://stackoverflow.com/', '_blank');" />
</form>
&#13;