日期:2014-05-16  浏览次数:20442 次

JS创建下拉框如何实现页面跳转
如下用JS创建下拉框后如何实现跳转:
<body >
<script type="text/javascript">
function createSelect()
{
  var select1 = document.createElement("select");
  var ooption = new Array();
  ooption[0] = "one";
  ooption[1] = "two";
  ooption[2] = "three";
  ooption[3] = "four";
  ooption[4] = "five";
   
   
  var optionValue = new Array();
  optionValue[0] = "1.html";
  optionValue[1] = "2.html";
  optionValue[2] = "3.html";
  optionValue[3] = "4.html";
  optionValue[4] = "5.html";
  for(var i=0;i<5;i++)
  {
  select1.options[i] = new Option(ooption[i], optionValue[i]);

  }
  document.body.appendChild(select1);
}
createSelect()
</script>
</body>


------解决方案--------------------
select1.onchange = function(){
location.href = this.value;
}
------解决方案--------------------
select1.onchange=function()
{
window.location.href=this.options[this.selectedIndex].value;
}