Html code:
<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>
I am only able to open it in the same tab, but how to open in a new tab?
You can open a new tab programmatically using window.open()
method by passing _blank
as window name.
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.