| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 481 人关注过本帖
标题:关于导航菜单的问题?各位高手请多多帮忙啊
只看楼主 加入收藏
iamjackaroo
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-4-18
收藏
 问题点数:0 回复次数:0 
关于导航菜单的问题?各位高手请多多帮忙啊
我是一名初学菜鸟,今日看到一个网站的导航菜单比较有特色(http://www.gdga.),而且还能结合cookie 记忆菜单状态,但我把其静态网页保存下来有待详细学习时,静态首页总是弹出错误提示“null:[object error] ”“error:undefined”
代码如下:
// JavaScript Document
$(document).ready(function(){
                           $.ajaxSetup({
                              cache: true
                            });

   
   
    /* 主菜单 */
    var navCookie = getCookie('navFix');
   
    if(navCookie){
        $('#btnOpenNav').addClass('current').attr('title','缩放');
        $('.mainNav').stop().css('height','110px');
        $('.mainNav').unbind();
        }else{
        $('#btnOpenNav').removeClass('current').attr('title','固定');
        $('.mainNav').stop().css('height','40px');
        navAnimate();
            }
            
    $('#btnOpenNav').toggle(
                           function(){
                                    $(this).addClass('current').attr('title','缩放');
                                    setCookie('navFix', true, 5);
                                    $('.mainNav').stop().css('height','110px');
                                    $('.mainNav').unbind();
                                    },
                            function(){
                                    $(this).removeClass('current').attr('title','固定');
                                    deleteCookie('navFix');
                                    //$('.mainNav').stop().css('height','40px');
                                    navAnimate();
                                });
   
    $('.mainNav ul li').hover(
                           function(){
                               //alert($(this).html());
                               $(this).find('p').addClass('current');
                               },
                           function(){
                               $(this).find('p').removeClass('current');
                               });
   
    function navAnimate(){
        $('.mainNav').hover(
                            function(){
                                $(this).stop().animate({height: '110px'}, "fast");
                              },
                            function(){
                                $(this).stop().animate({height: '40px'}, "fast");
                            });
        }
        
        
   


/* cookies */
    function getCookie(Name) {
    var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
    if (document.cookie.match(re)) //if cookie found
    return document.cookie.match(re)[0].split("=")[1] //return its value
    //return null
    }
    function setCookie(name, value, days) {
    var expireDate = new Date()
    //set "expstring" to either future or past date, to set or delete cookie, respectively
    var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
    document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
    }
    function deleteCookie(name){
    var expires = new Date();
    expires.setTime(expires.getTime() - 1);
    setCookie(name, '', expires)
    //setCookie(name, "moot")
    }
   
/*网站地图fucntion*/
function getparentid(ni){
    var pid = '';
    $.ajax({
       url: '/siteNav.xml',
       type: 'GET',
       dataType: 'xml',
       async: false,
       cache: true,
       //cache: false,
       global: false ,
       success: function(xml){
           //alert(xml);
           pid = $(xml).find('nav > menu[id="'+ni+'"]').attr('parentid');
       },
       error: function(XMLHttpRequest, textStatus, errorThrown){
            alert(textStatus+":"+errorThrown);
        }
    });
    return pid;
    }
function siteNavXml(ni){
        $.ajax({
       url: '/siteNav.xml',
       type: 'GET',
       dataType: 'xml',
       //cache: false,
       global: false ,
       success: function(xml){
           //alert(xml);
           if($(xml).find('nav > menu[parentid="'+ni+'"]').size() != 0){
               
               $('#siteNavCon').empty();
           $(xml).find('nav > menu[parentid="'+ni+'"]').each(function(i){
                var txt = '';
                txt += '<a href="';
                txt += $(this).find('link').text();
            
            if($(this).find('link').text() == 'javascript:;'){
                txt += '" class="siteNavFile';
                }else{
                txt += '" class="siteNavLink" target="_blank';   
                    }
               
                txt += '" title="';
                txt += $(this).find('title').text();
                txt += '" id="'
                txt += $(this).attr('id');
                //txt += '" parentid="'
                //txt += $(this).attr('parentid');
                txt += '" >';
                txt += $(this).find('name').text();
                txt += '</a><br />';
                $('#siteNavCon').append(txt);
                                                         });
               
               
               
               
               }
           
       },
       error: function(XMLHttpRequest, textStatus, errorThrown){
            alert(textStatus+":"+errorThrown);
        }
    });
}

   
                           });
因为本人实在是看不懂了,恳请各位能够指点迷津啊,谢谢了
搜索更多相关主题的帖子: undefined function cookie null 
2011-04-18 18:37
快速回复:关于导航菜单的问题?各位高手请多多帮忙啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024413 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved