zoukankan      html  css  js  c++  java
  • 为了不重复_nav

    //企业站的一级目录,二级目录的焦点,

    页面的命名:aboutus.php ; aboutus_tissue.php ; aboutus_partners.php ; aboutus_culture.php

    var navaddNow = Class.create();
    navaddNow.prototype = {
        initialize: function(id,a){
        if(document.getElementById(id)){
            this.nowA = document.getElementById(id).getElementsByTagName("a");
            this.choseOne(a);
            }
        },
        getmenuNow: function(){
            var url = location.href.split("/");
            var rex = /[a-z]+/;
            var res = url[url.length-1].match(rex).toString();
            for(var i=0; i<this.nowA.length; i++){
                var a = this.nowA[i].href.split("/");
                var c = a[url.length-1].match(rex).toString();
                if(c == res){
                    this.nowA[i].className = "now";
                    return;
                    }
                }
        },
        getnavNow: function(){
            var url = location.href.split("/");
            var urlx = url[url.length-1].split(".")[0];
            var num;
            for(var i in this.setnum){
                if(urlx==i) num = this.setnum[i];
                }
            this.nowA[num].className = "now";
        },
        setnum: {
            "aboutus"                  :0,
            "aboutus_tissue"       :1,
            "aboutus_partners"      :2,
            "aboutus_culture"      :3
            },
        choseOne: function(x){
            switch(x){
                case "1" : this.getmenuNow(); break;
                case "2" : this.getnavNow(); break;
                }
            }
    }
    new navaddNow("nav","2");

  • 相关阅读:
    函数
    向discuz里填充数据
    CI 基础
    FlashBuilder设置显示字符集
    win2003 Email邮件服务器搭配
    CI 模块化显示[仿照shopex功能]
    DW的鸟语
    CI 视图里加视图
    silverlight模拟单击事件
    自定义XML配置文件的操作类(转)
  • 原文地址:https://www.cnblogs.com/somesayss/p/2488876.html
Copyright © 2011-2022 走看看