Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7786527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:25:53+00:00 2026-06-01T20:25:53+00:00

What is wrong in this code? function FloatMenu() { var scrollAmount = $(document).scrollTop(); var

  • 0

What is wrong in this code?

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);

    }
}​

The full code:

/* Floating Menu */
//config
$float_speed=500; //milliseconds
$float_easing="easeOutQuint";
$menu_fade_speed=500; //milliseconds
$closed_menu_opacity=0.75;

//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, $closed_menu_opacity);
            $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);
    }
}                      

errors are:

Message: 'menuPosition' is undefined 

and

Message:'position().top' is null or not an object
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:25:54+00:00Added an answer on June 1, 2026 at 8:25 pm

    try declaring menuPosition outside of the function’s scopes:

    var menuPosition = 0; // declared outside of function scopes
    
    /* Floating Menu */
    //config
    $float_speed=500; //milliseconds
    $float_easing="easeOutQuint";
    $menu_fade_speed=500; //milliseconds
    $closed_menu_opacity=0.75;
    
    //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, $closed_menu_opacity);
                $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);
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anybody tell me what is wrong with this code ?? jQuery(document).ready(function(){ var val
What's wrong with this code? Why doesn't it show value? <script> $(document).ready(function() { $('#radio_div').change(function(event){
Title is descriptive, what is wrong with this code and why? <script type=text/javascript> $(document).ready(function()
What's wrong with this code? jQuery $(document).ready(function() { $(#routetype).val('quietest'); )}; HTML <select id=routetype name=routetype>
I have no idea what's wrong with this code: onupgradeneeded = function(){ z =
What's wrong with this code? I'm not able to validate 'data': $.post('http://localhost/do.php', function(data) {
What is wrong with this code? <?php class users { var $user_id, $f_name, $l_name,
I have figure out this code function getAllProperties(obj){ var result={ properties:[], methods:[] }; var
What is wrong with this code? I am using jQuery. function setPreviewUrl() { $post_title
Does anyone know what's wrong with this code block. CREATE FUNCTION [dbo].[udfGetPoint] ( @UserID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.