问题
How can I open each link in this select box in a new window?
<form name="jump">
<select name="menu">
<option value="http://">link</option>
<option value="http://">link</option>
<option value="http://">link</option>
</select>
<input type="button" onClick="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO" />
</form>
回答1:
The correct function for a new window is window.open();
<form name="jump">
<select name="menu">
<option value="http://">link</option>
<option value="http://">link</option>
<option value="http://">link</option>
</select>
<input type="button" id="button"
onclick="window.open(document.jump.menu.options[document.jump.menu.selectedIndex].value);" value="GO" />
</form>
Note: Writing in line javascript can be messy. try separating your javascript from your presentation
来源:https://stackoverflow.com/questions/13571718/how-to-open-a-link-in-a-select-box-in-a-new-window