逐浪云主机

立即开通

js(select onchange)的网页跳转的两种模式介绍

作者:本站编辑 发布时间:2011-11-03 来源:本站原创 点击数:

方法一:
<Select onChange="javascript:if(this.options[this.selectedIndex].value) window.open(this.options[this.selectedIndex].value)"  size=1 name=select8>
<Option selected>选择实例</Option>
<Option value="http://www.hx008.com">→ 华夏互联</Option>
<Option value="http://www.zoomla.cn">→ 逐浪软件</Option>
</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.,如果还有不懂,请浏览zoomla.cn官网的友情链接示范。

本文责任编辑: 加入会员收藏夹 点此参与评论>>
复制本网址-发给QQ/微信上的朋友