[英]opening a new tab by selecting from options html
I'm currently using < select > tags and < option > tags each with their own value attributes and using it link to a new page. 我当前正在使用<选择>标记和<选项>标记,它们分别具有自己的值属性,并使用其链接到新页面。
This is my code: 这是我的代码:
<div class="label">
<label> Select your online bank login: </label>
<select id="selectBank">
<option value="https://ipn.paymentus.com/epd/stde/lhud"> Paymentus </option>
<option value="https://www12.bmo.com/onlinebanking/cgi-bin/netbnx/NBmain"> BMO </option>
<option value="https://www.myvisaaccount.com/Vancity_Consumer/Login.do"> Citizens' Bank of Canada </option>
<option value="https://bvi.bnc.ca/auth/Login"> National Bank of Canada </option>
</select>
<button onclick="goToBankLogin()"> Login </button>
and this is the javascript code for selecting values, right now it opens into a new page: 这是用于选择值的javascript代码,现在它会打开一个新页面:
function goToBankLogin() {
var selectedBank = selectBank.options[selectBank.options.selectedIndex].value;
window.location.replace(selectedBank.toString());
}
and i need it to open to a new tab, how would i do this? 我需要它打开一个新选项卡,我该怎么做?
Okay, just playing around and figured this out, it works for me and opens up a new tab 好吧,只是玩转并弄清楚了,它对我有用,并打开了一个新标签
changed up my function a bit: 改变了我的功能:
function goToBankLogin() {
var selectedBank = selectBank.options[selectBank.options.selectedIndex].value;
window.open(selectedBank.toString());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.