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