输入时单击新建选项卡


<form name="test">
<select name="choose" style="width:300px;">
<option selected="">Select option</option>
<option value="http://url.com">Test</option>
</select>
<input onclick="location=document.test.choose.options[document.test.choose.selectedIndex].value;" value="Take me there!" type="button"></p>
</form>

我使用以下方法制作下拉列表,只是想知道如何在新选项卡中而不是在其自己的窗口中打开所选内容

工作正常,因为它只需要在新选项卡中打开。

*编辑*

这根据需要工作,谢谢

<input onClick="window.open(document.test.choose.options[document.test.choose.selectedIndex].value);" value="Take me there!" type="button">

try window.open

window.open('http://www.google.com');

更新

现场演示 - http://jsfiddle.net/im4aLL/tzp4H/

function open_in_new_tab(url )
{
  var win=window.open(url, '_blank');
  win.focus();
}

如果要在新选项卡中打开链接,请调用该函数。也检查这里和这里

关于您对原始帖子的更新答案:

.value后添加,'_blank',如下所示:

<input type="button" onClick="window.open(document.test.choose.options[document.test.choose.selectedIndex].value,'_blank');>

实际上在新选项卡中打开,而不是在全新的浏览器窗口中打开。

没有高级或类似的内容。您只需添加_blank,如以下示例所示。

  <a href="someLink.html" target="_blank">
      <button>Visit my Github</button>
  </a>

最新更新