HTML中select选择菜单跳转“当前窗口”或“新窗口”
发布时间:2010-08-04 10:04 文章作者:Pop's Blog
摘要:select选择菜单的链接方式主要由onchange来控制,下面是代码: 在新窗口中打开: select onchange = window.open(this.options[this.selectedIndex].value) name = select 在当前窗口打开: select onchange = 'document.location.href=this.options[this.se...
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://">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://">Pop's Blog</option>
- <option value="http://www.qq.com">Tencent</option>
- <option value="http://www.google.com">Google</option>
- </select>
|