[英]How to open a new tab when I select a option in Select Tag?
Html 代码:
<body>
<h1>Select the country you want to know about</h1>
<br>
<form>
<select name="Countries and its Name" onchange="location = this.value;">
<option selected>---Select---</option>
<option value="india.html">India</option>
<option value="usa.html">United States of America</option>
</select>
</form>
</body>
我只能在同一个选项卡中打开它,但是如何在新选项卡中打开它?
您可以使用window.open()
方法通过将_blank
作为 window 名称以编程方式打开一个新选项卡。
<h1>Select the country you want to know about</h1>
<br>
<form>
<select name="Countries and its Name" onchange="window.open(this.value, '_blank')">
<option selected>---Select---</option>
<option value="india.html">India</option>
<option value="usa.html">United States of America</option>
</select>
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.