方法一:
<select onchange="goUrl(this.options[this.selectedIndex])">
<option>==</option>
<option value='http://www.csdn.net' target="_blank">csdn</option>
<option value='http://www.163.com' target="_self">163.com</option>
</select>
<script>
function goUrl(obj){
if(obj.target=='_blank')window.open(obj.value);
if(obj.target=='_self')location.href=obj.value;
}
</script>
方法二:
TE>TE>
select页面跳转及获值
- <select onchange="window.location.href=this.options[selectedIndex].value" >
- <option value="http://www.google.com" >谷歌</option>
- <option value="http://www.yahoo.com" >雅虎</option>
- <option value="http://www.baidu.com" >百度</option>
- </select>
这里主要用到 :
1.window.location.href 跳转,如果想在新窗口中打开,可以用 window.open(this.options[selectedIndex].value).
2.this.options[selectedIndex].value取值.
注意:javascript是严格区分大小写的!只能写成selectedIndex.