HTML中select选择菜单跳转“当前窗口”或“新窗口”

select选择菜单的链接方式主要由“onchange”来控制,下面是代码:

在新窗口中打开:
<select onchange="window.open(this.options[this.selectedIndex].value)" name="select">

在当前窗口打开:
<select onchange='document.location.href=this.options[this.selectedIndex].value;'>

下面是实际应用中的完整代码,供大家参考

1、在新窗口中打开 示例代码:

<select onchange="window.open(this.options[this.selectedIndex].value)" name="select">
<option value="http://429006.com">Pop's Blog</option>
<option value="http://www.qq.com">Tencent</option>
<option value="http://www.google.com">Google</option>
</select>

2、在当前窗口打开 示例代码:

<select onchange='document.location.href=this.options[this.selectedIndex].value;'>
<option value="http://429006.com">Pop's Blog</option>
<option value="http://www.qq.com">Tencent</option>
<option value="http://www.google.com">Google</option>
</select>

This entry was posted in Technology and tagged , , . Bookmark the permalink. 5,202 views

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *