试图创建ie9友好版本的工作代码

时间:2015-06-25 14:05:19

标签: javascript jquery

所以我有一个很棒的多重菜单...它有一个js文件,你可以添加一些东西,当菜单被激活时也会被推送,这也很棒...问题是ie9没有&#39 ;了解jquery插件,我正在尝试创建一个ie9片段,以帮助这里是原始代码......

$(document).ready(function(){
    // HTML markup implementation, overlap mode
    $( '#menu' ).multilevelpushmenu({
        containersToPush: [$( '.tile-area-title'), ( '.navbtn'), ( '.tile-area-main' ), ('#logo-title'), ('.submenu-ctn')],
        collapsed: true,

        // Just for fun also changing the look of the menu
        wrapperClass: 'mlpm_w',
        menuInactiveClass: 'mlpm_inactive'
    });

这是.navbtn的代码,当点击时做一些也适用于所有浏览器的东西......

$(document).ready(function () {
    var $navToggle = $('.nav-toggle');
    $(".navbtn").click(function (e) {
        e.stopPropagation();
        if($navToggle.hasClass('active')){
            $('#menu').multilevelpushmenu('collapse');
            $navToggle.removeClass('active');
            $(this).addClass('active');
        }
        else{
            $('#menu').multilevelpushmenu('expand');
            $navToggle.addClass('active');
            $(this).removeClass('active');
        }
    });

    $(".navbtn").hover(function () {
        $('.nav-toggle').addClass('hover');
    },function(){
         $('.nav-toggle').removeClass('hover');
    });

    $('#menu').on('click', function(e) {
         e.stopPropagation();
    });


    $('body').on('click', function(e){
        $('#menu').multilevelpushmenu('collapse');
        $navToggle.removeClass('active');
    });
});

但是我已经添加了这个检测并添加了一些脚本,我已将其附加到上面的代码中......

if ((old_ie > -1) || (new_ie > -1)) {
            ms_ie = true;
            }
                if ( ms_ie ) {
               $(".navbtn").click(function (e) {
              ({
        containersToPush: [$( '.tile-area-title'), ( '.navbtn'), ( '.tile-area-main' ), ('#logo-title'), ('.submenu-ctn')],
        collapsed: false


    });
                }

)} 

但它不起作用......我想要做的就是在菜单打开/关闭时在屏幕上推几个课程,有人可以帮忙吗?

编辑: -

单击菜单按钮时,f12开发人员选项会显示以下内容....

multilevelpushmenu.js, line 612 character 6
SCRIPT5007: Unable to get value of the property 'defaultView': object is null or undefined 

,这与js文件中的此代码有关...

// Push container(s) of choice
            function pushContainers( absMove ) {
                if( instance.settings.containersToPush == null ) return false;
                $.each( instance.settings.containersToPush, function() {
                    var lMr = parseInt( $( this ).css( 'margin-left' ) ),
                        lM = isInt( lMr ) ? lMr : 0,
                        rMr = parseInt( $( this ).css( 'margin-right' ) ),
                        rM = isInt( rMr ) ? rMr : 0;
                    $( this ).stop().animate({
                        marginLeft:  lM + ( ( instance.settings.direction == 'rtl' ) ? (-1) : 1 ) * absMove,
                        marginRight: rM + ( ( instance.settings.direction == 'rtl' ) ? 1 : (-1) ) * absMove
                    });
                });
            }

...所以我认为函数pushContainers不适合ie9?

0 个答案:

没有答案