按钮/下拉菜单在新窗口中打开

问题描述 投票:0回答:1

因此,我做了一个小网站,它提供了一些下拉选项供我们公司使用。我正在尝试获取我创建的“开始”按钮,以从新选项卡中的下拉列表中打开链接,那样您就不会丢失页面,因为它当前在与帮助页面相同的选项卡中打开链接。我将在下面粘贴一个示例,如果可以得到任何帮助,则将是

<select id="Polynesian">
  <option value="#">Choose a CMTS</option>
  <option value="http://MYURL1/">Pond</option>
  <option value="http://MYURL2/">Beach</option>
</select>
<button id="go" onclick="gotosite()">Go</button>

这是我为每个按钮创建的按钮js。

function gotosite() {
  window.location = document.getElementById("GulfPlace").value; // JQuery:  $("#GulfPlace").val();
  window.location = document.getElementById("Polynesian").value; // JQuery:  $("#Polynesian").val();
  window.location = document.getElementById("GrandCaribbean").value; // JQuery:  $("#GrandCaribbean").val();
  window.location = document.getElementById("DunesOfSeagrove").value; // JQuery:  $("#DunesOfSeagrove").val();
  window.location = document.getElementById("PinnaclePort").value; // JQuery:  $("#PinnaclePort").val();
}
javascript html jquery
1个回答
0
投票

您可以将window.open()_blank选项一起使用以在新选项卡中打开

 function gotosite() {
  window.open(document.getElementById("GulfPlace").value,'_blank'); // JQuery:  $("#GulfPlace").val();
  window.open(document.getElementById("Polynesian").value,'_blank'); // JQuery:  $("#Polynesian").val();
  window.open(document.getElementById("GrandCaribbean").value,'_blank'); // JQuery:  $("#GrandCaribbean").val();
  window.open(document.getElementById("DunesOfSeagrove").value,'_blank'); // JQuery:  $("#DunesOfSeagrove").val();
  window.open(document.getElementById("PinnaclePort").value,'_blank'); // JQuery:  $("#PinnaclePort").val();
}
© www.soinside.com 2019 - 2024. All rights reserved.