ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

javascript error, please someone can take a look on my code?!

January 02, 2011 8:36pm

Subscribe [2]
  • #1 / Jan 02, 2011 8:36pm

    manimac

    8 posts

    hi all! as i told you many times, my english is so bad than like my coding skills!
    i need help with this js code, it result 2 errors and i dont understand what i have to do to correct the script -(

    i talk about a script for a floating menu, this is the code:

    /* Float Utility Menu */
    
    $(document).ready(function() {
    
    //config
    $float_speed=1500; //milliseconds
    $float_easing="easeInOutQuart";
    $menu_fade_speed=350; //milliseconds
    
    //cache vars
    $fl_menu=$("#fl_menu");
    $fl_menu_menu=$("#fl_menu .menu");
    $fl_menu_label=$("#fl_menu .label");
    
    $(window).load(function() {
        menuPosition=$('#fl_menu').position().top;
        FloatMenu();
        $fl_menu.hover(
            function(){ //mouse over
                $fl_menu_label.fadeTo($menu_fade_speed, 1);
                $fl_menu_menu.fadeIn($menu_fade_speed);
            },
            function(){ //mouse out
                $fl_menu_label.fadeTo($menu_fade_speed, 1);
                $fl_menu_menu.fadeOut($menu_fade_speed);
            }
        );
    });
    
    $(window).scroll(function () { 
        FloatMenu();
    });
    
    function FloatMenu(){
        var scrollAmount=$(document).scrollTop();
        var newPosition=menuPosition+scrollAmount;
        if($(window).height()<$fl_menu.height()+$fl_menu_menu.height()){
            $fl_menu.css("top",menuPosition);
        } else {
            $fl_menu.stop().animate({top: newPosition}, $float_speed, $float_easing);
        }
    }
    
    });

    in Safari or other browser I can see two evil red errors like you see in my attachment screenshot.
    please if someone could help me I would be happy!

    many thanks
    vito.

  • #2 / Jan 14, 2011 11:56am

    Joe Paravisini

    50 posts

    maybe try either without those cache vars or using the cache var when setting menuPosition. e.g.    menuPosition=$fl_menu.position().top;
    The second error is only tripped because menuPosition is not successfully setting, so if you fix that the second error should go away.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases