js 下拉框选中跳转

选中后跳转

<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ, selObj, restore) { //v3.0
    alert(selObj.selectedIndex);
    eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
    if (restore) { //selected=true
        selObj.selectedIndex = restore;
    } else {
        selObj.selectedIndex = 0;
    }
}
//-->
</script>

<form name="form1" id="form1">
  <select name="menu1" onchange="MM_jumpMenu('parent',this,0)">
    <option value="http://www.baidu.com">baidu</option>
    <option value="http://www.sohu.com">sohu</option>
  </select>
</form>

<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  window.open(selObj.value);
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
    <option value="http://www.21cn.com">21cn</option>
    <option value="http://www.163.com">163</option>
</select>

你可能感兴趣的:(下拉框)