代码改变世界

根据select的选项不同跳转到不同的页面

2013-03-11 14:17  Truke  阅读(393)  评论(0编辑  收藏  举报

跳转到当前页:(主要是location.href="")
<select name="here " onchange="location.href=this.options[this.selectedIndex].value;">
    <option  value= "http://www.qq.com "> 腾讯 </option>
    <option  value= "http://www.sina.com "> 新浪 </option>
    <option  value= "http://www.baidu.com "> 百度 </option>
</select>


跳转到新页面:(主要是window.open(""))
<select onchange="window.open(this.options[this.selectedIndex].value)" name="select">
 <option value="http://www.qq.com" selected="selected">腾讯</option>
 <option value="http://www.sina.com">新浪 </option>
 <option value="http://www.baidu.com">百度 </option>
</select>