Home  >  Article  >  Web Front-end  >  javascript实现跳转菜单的具体方法_javascript技巧

javascript实现跳转菜单的具体方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:29:47920browse

传统

javascript实现跳转菜单的具体方法_javascript技巧

这里要做的是,省略Go There按钮,选择菜单项后,直接跳转。

javascript实现跳转菜单的具体方法_javascript技巧

Html代码

复制代码 代码如下:

 
 
 
 
转移菜单 
 
 
 
 
   
   
  
 
 
 

Javascript脚本
复制代码 代码如下:

window.onload=initForm; 
//防止页面缓存,无法触发onload  
window.onunload=function(){} 
    function initForm(){ 
        document.getElementById("newLocation").selectIndex=0; 
        document.getElementById("newLocation").onchange=jumpPage; 
        } 
    function jumpPage(){ 
        var newLoc=document.getElementById("newLocation"); 
        var newPage=newLoc.options[newLoc.selectedIndex].value; 
        if (newPage!=""){ 
            window.location=newPage; 
            } 
        } 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn