<select id="select" onchange="this.options[this.selectedIndex].value
&& (window.location = this.options[this.selectedIndex].value);">
<option value="">Choose your state</option>
<option value="http://www.treasury.state.al.us/Content/index.aspx">Alabama</option>
<option value="http://treasury.dor.alaska.gov/">Alaska</option>
I've tried looking at other examples, but I'm not sure where to add the "_blank" target attribute to this code to let the link open in a new window/tab. Any help would be appreciated.
Thank you!
Use the window.open function instead of the window.location variable. Window.location is meant to redirect the document itself. Window.open opens a new window.
Try window.open(this.options[this.selectedIndex].value)
instead.
<select id="select" onchange="window.open(this.options[this.selectedIndex].value);">
<option value="">Choose your state</option>
<option value="http://www.treasury.state.al.us/Content/index.aspx">Alabama</option>
<option value="http://treasury.dor.alaska.gov/">Alaska</option>
</select>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments